MakeCode JoyCar Sensors
Check the ultrasonic sensor for the distance to the nearest detected object. The function returns the distance in response.
Checks the left/right speed sensor whether the signal was interrupted by the perforated disk. The function returns True or False.
Checks the left/right obstacle sensor to see if an obstacle has been detected. The function returns True or False.
Checks the left/middle/right linefinder sensor whether a line on the floor could be detected. The function returns true or false (True/False) as answer.
In this example, as soon as button A is pressed, the distance to the nearest object is measured and displayed via the ultrasonic sensor.
For this example, the Joy-Car must stand on a white sheet of paper. If a black strip is now moved under one of the three Linefinder sensors, a line appears on the display of the Micro:bit. Depending on the sensor in use, the line is arranged on the left, in the middle, or on the right. The corresponding blinker is activated if the black strip is pushed under the left or right linefinder sensor.
In this example, the obstacle sensors are activated. As soon as an obstacle is pushed in front of the Joy-Car, the Joy-Car automatically moves back to a certain distance.
In this example, the speed sensor is activated. The left wheel of the Joy-Car can be turned by hand here. The perforated disc fields are then automatically counted and displayed on the console via the serial interface.
Here, the speed sensors are used to rotate one full rotation per wheel in succession.