Introduction
We may program to make the Cutebot turn on its directional lights while it turns. It’s also possible to control the lights via Joystick:bits or sensors, here I’ve programmed to change its driving status at random for each scheduled time.
Materials required
The Cutebot(https://www.elecfreaks.com/micro-bit-smart-cutebot.html)
Programme
We need to initialize the clearance lamps at first. Drag show icon to on start brick, initialize the strip connected to P15 by assigning 2 pieces LEDs, set the headlights light on in white.
If we want the car to drive randomly, we need to set two variables with random values from 0 to 100, and then use the values of the two variables as the speed of the left and right wheels.
Judge the speed of both wheels. When the speed of the left wheel is bigger than the speed of the right, turn on the light on the right; when the left wheel speed is less than the right wheel, turn on the light on the left, and then delay 2000ms.
Program:
Link:https://makecode.microbit.org/_FHx2ov36vCYx
Result
After powering on, the LED screen of the micro:bit displays a preset icon, the headlights light up in white, the Cutebot randomly changes its driving direction every two seconds, and lights up the corresponding turn indicator lights.