EasyManua.ls Logo

Keyestudio Micro:bit Mini Smart Robot Car V2 - Page 112

Keyestudio Micro:bit Mini Smart Robot Car V2
184 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
86
Programming Thinking
1 Set the KEYES-2812-18R module to turn on 18 RGB LEDs in various colors.
When micro:bit robot moves forward, 18 RGB LEDs turn on blue light;
robot moves backward, 18 RGB LEDs turn on purple light; turn left, 18 RGB LEDs turn on green light;
turn right, 18 RGB LEDs turn on yellow light; robot stops, 18 RGB LEDs turn on red light.
2 Measure the distance between the robot and obstacles ahead by an ultrasonic sensor. Use 2 infrared
detector sensors to detect the obstacles on both sides of micro:bit robot.
3 When the measured distance is greater than 3cm but less than or equal to 6cm, no obstacles at both sides,
micro:bit robot stops. If less than or equal to 3cm, obstacles detected at both sides, robot moves backward;
If greater than 6cm, no obstacles detected at both sides, robot moves forward;
If greater than 3cm, obstacles are at right side but not left side, robot turns right;
If greater than 3cm, obstacles are at left side but not right side, robot turns left;
If greater than 6cm, obstacles detected at both sides, robot moves backward;
for other status, robot stops.