6. MakeCode Graphical Programming
•
How to use MakeCode:
https://wiki.dfrobot.com/Makecode%20Get-started%20Tutorial
•
MakeCode Library Address:
https://github.com/DFRobot/pxt-DFRobot_MaqueenPlus_v20
6.1 Light-controlled Maqueen Plus
The following program calls the light sensor of the micro:bit motherboard. Normally, the car is
in a stopped state, and the RGB light at the bottom lights up in color. When the flashlight
illuminates the front side of the micro:bit, the car goes forward, the bottom RGB light goes out,
and the front lights turn on.
The value of the light sensor is an analog value between 0 and 255, which is used to indicate the
intensity of light. In the program, we take a light intensity value of 100 as the demarcation point.
When the light intensity is greater than 100, the car is started, otherwise, the car is stopped.
https://makecode.microbit.org/_26hJo3HLbaqw
6-2 Sound-controlled Maqueen Plus(only supports micro:bit V2.0)
The following program calls the sound sensor on the micro:bit V2 motherboard. When you clap
your hands, the car starts to drive and turns on the lights. When you clap your hands again, the
car stops and turns off the lights. Repeat in this way.
In the program, when the sound is detected to be greater than 100, the state of a Boolean value is
reversed. Next, the program checks whether the Boolean value is true, if it is true, the car moves
forward, if it is false, the car stops.