Welcome to Building:bit Superkit repository
2.4 MakeCode graphical API
MakeCode graphical API
A. SuperBit V2
1)
Function: Set the buzzer on the expansion board to play a certain music
2)

Function: Set the servo to a certain angle
Parameters: Number: Corresponding servo interface S1-S8 Angle: Set 0-1 according to the servo angle range 80, 0-270
For example:
3)

Function: Set the servo to rotate in a certain direction at a certain speed
Parameters: Number: Corresponding servo interface S1-S8 Speed: 0-90 Direction: forward, reverse, stop
For example:
4)
Function: Set a single motor to rotate at a certain speed
Parameter: Number: Corresponding motor interface M1-M4 Speed: Set the motor rotation speed -255~255, negative value means reverse
For example:
5)
Function: Set two motors to rotate at a certain speed at the same time
Parameters: Number: Corresponding motor interface M1-M4 Speed: Set the motor rotation speed -255~255, negative value means reverse
For example:
6)
Function: Stop all motors
B. SuperBit V2 Digital Class
1)
Function: Temperature and humidity values detected by the DHT11 sensor
Parameters: Value: Detected temperature in Celsius (℃), Fahrenheit (℉), humidity (0~100) Pin: The sensor is connected to the corresponding pin on the expansion board
For example:
2)
Function: Distance detected by ultrasonic wave
Parameters: Pin: The corresponding pin on the expansion board to which the sensor is connected
For example:
3)
Function: Set a state returned by the human infrared sensor as a judgment condition
Parameters: Pin: The corresponding pin on the expansion board to which the sensor is connected
State: The state returned by the sensor Someone is moving and No one is moving
For example:
4)
Function: Set a state returned by the infrared sensor as a judgment condition
Parameters: Pin: The corresponding pin on the expansion board to which the sensor is connected State: Obstacle and No obstacle returned by the sensor Two states
For example:
5)
Function: Set a certain state of the button as a judgment condition
Parameters: Pin: The button is connected to the corresponding pin on the expansion board State: The button is pressed and released Two states
For example:
6)
Function: Set a state of the collision detection sensor as a judgment condition
Parameters: Pin: The sensor is connected to the corresponding pin on the expansion board State: No collision and Collision returned by the sensor Two states
For example:
7)
Function: Set the vibration sensor to a certain state
Parameters: Pin: The sensor is connected to the corresponding pin on the expansion board
For example:
C. SuperBit V2 Perception category
1)
Function: The value detected by the light sensor. The lower the brightness, the larger the value returned
Parameters: Pin: The corresponding pin on the expansion board to which the sensor is connected
For example:
2)
Function: The analog value output by the sound sensor, the range is 0~1023, the louder the sound, the greater the output analog value
Parameters: Pin: The sensor is connected to the corresponding pin on the expansion board
For example:
3)
Function: The current resistance value of the potentiometer
Parameters: Pin :The sensor is connected to the corresponding pin on the expansion board
For example:
4)
Function: Set a state of the joystick as a judgment condition
Parameter: Pin: The joystick is connected to the corresponding pin on the expansion board State: The joystick has 5 states: None, Up, Down, Left, Right
For example:
D. SuperBit V2 PWM class
1)
Function: Set the buzzer to be connected to a certain pin
Parameters: Pin: The sensor is connected to the corresponding pin on the expansion board
For example:
2)
Function: Set the vibration motor to vibrate at a certain speed
Parameters: Pin: The sensor is connected to the corresponding pin on the expansion board Speed: Vibration speed, range 0-1023
For example:
3)
Function: Set the R, G, and B values of the RGB light to change the color
Parameters: Pin: The sensor is connected to the corresponding pin on the expansion board Red, green, blue: RGB value of the light, range 0-255
For example:
4)
Function: Set the color of the RGB light
Parameters: Pin: The sensor is connected to the corresponding pin on the expansion board Color display: Off and several fixed colors
For example:
E. Neopixel
1)
Function: Create and initialize a light strip
Parameters: Pin: The pin connected to the light strip Number of beads: The number of beads waiting to be connected Mode: The mode used by the light beads, including RGB (GRB order), RGB + W, RGB (RGB order)
For example:
2)
Function: Select a range from the color light strip, starting from a certain light, and select a certain number of lights.
Parameters:
Pixels: starting position of the light
Length: the number of selected lights
For example:
3)
Function: let the light strip present a gradient color effect in a certain hue range
Parameters: Hue: range 0-360 (complete color circle)
For example:
4)
Function: Let the light strip present a certain color
Parameter: Color: Several fixed colors, such as red, orange, yellow, violet, etc.
For example:
5)
Function: Display the value on the LED light strip in the form of a bar graph.
Parameters: Value: the currently displayed value Maximum value: the maximum value that can be set. When set to this maximum value, all the lamp beads will light up
For example:
6)
Function: Refresh the display of the light strip
7)
Function: Clear the display of the light strip, that is, turn off the light
8)
Function: Convert hue, saturation, and brightness values to RGB colors
Parameters: Hue: Range 0-360 Saturation: Range 0-99 Brightness: Range 0-99
For example: 
9)
Function: Control the light strip to move at a certain pixel. Move the pixels of the light strip forward by a specified number of pixels, and use "0" (i.e. closed pixels) to clear the position left at the end
Prerequisite: After use, you need to call Refresh Display to display the changes
Parameters: Offset: The pixels moved by the light strip
For example: 
10)
Function: Control the light strip to circulate with a certain pixel, that is, move the front pixel to the back
Prerequisite: After use, you need to call Refresh Display To display the changes
Parameters: Offset: The pixel that the light strip moves
For example:
11)
Function: Set the brightness of the white light at a certain pixel position
Prerequisite: Only applicable to RGBW lamp beads (not ordinary RGB lamp beads). After use, you also need to call Refresh Display to display the changes
Parameters: Pixel: The number of lamp beads to be set (from 0 Start counting) Brightness: Range 0-255
For example:
12)
Function: Set the lamp bead at a certain pixel position on the light strip to display a certain color
Prerequisite: After use, you also need to call Refresh Display to display the changes
Parameters: Pixel: The number of lamp beads to be set (from 0 Start counting) Color: The color to be displayed on the light strip
For example:
13)
Function: Get the number of lamp beads on the light strip
14)
Function: Set the brightness of the light strip
Parameters: Brightness: Range 0-255, the larger the value, the brighter it is
15)
Function: Reduce the brightness of the light strip
16)
Function: Estimate the current consumed by the current lighting configuration
17)
Function: Set the number of lamp beads per row of the light strip, the direction of the entire matrix, and the arrangement method
Prerequisite: It is a matrix-shaped light strip or light board
Parameters:
width: The number of lamp beads per row
rotation: Rotation method 0-NeoRotation.Rotate0 (no rotation), 1-NeoRotation.Rotate90 (90 degrees clockwise), 2-NeoRotation.Rotate180 (upside down), 3-NeoRotation.Rotate270 (270 degrees clockwise)
chain: arrangement 0-NeoMatrixChain.None (normal arrangement), 1-NeoMatrixChain.ZZ (Z-shaped arrangement)
18)
Function: Set the color of the lamp beads at the specific coordinate position on the matrix-shaped light strip
Prerequisite: It is a matrix-shaped light strip or light board
Parameters: x, y: horizontal and vertical coordinates Color: The color displayed by the lamp beads