Connection
Ultrasonic sensor (US-015)
VCC: Connect the 3V3 output of the micro:bit - it provides power to the sensor.
GND: connect to GND pin MB3.
Trig: connect to pin P9 – it is used to send an ultrasonic pulse.
Echo: connect to pin P8 – it receives the reflected signal and allows distance calculation.
LED strip
DIN (signal): connect to pin P1 – controls the lighting of individual LEDs.
VCC: Connect the 3V3 output of the micro:bit.
GND: connect to the ground pin of the micro:bit (GND).
Servo motor
Signal wire: connect to pin P0 – allows servo rotation control.
VCC: Connect the 3V3 output of the micro:bit.
GND: connect to the ground pin of the micro:bit (GND).
Power supply
INPUT +: connect the positive pole of the battery box.
INPUT –: connect the negative pole of the battery box (GND).
Warning: Always make sure the micro:bit is disconnected from power before connecting any devices to avoid damaging the electronics.
Program
Basic program
After starting the program, it sets the LED strip (6 diodes on pin P1), the limit distances (1–40 cm) and the initial position of the servo on pin P0. The ultrasonic sensor (Trig P8, Echo P9) constantly measures the distance to the obstacle in centimeters.
The servo rotates continuously from 0° to 180° and back, simulating a radar scan of the space. The measured distance is converted into the number of lit LEDs - green for greater distances, orange for medium distances and red for small distances.
Sound notification
After starting the program, it sets the LED strip (6 diodes on pin P1), brightness, limit distances (1–40 cm), measurement filtration using the coefficient alpha and the servo's initial position on pin P0. The ultrasonic sensor (Trig P8, Echo P9) continuously measures the distance, and the value is smoothed (combining the previous and new values) to make the measurement more stable. The servo rotates continuously from 0° to 180° and back, simulating radar.
The measured distance is mapped to the number of lit LEDs – green indicates a greater distance, orange a medium distance and red a short distance. If the object is very close (≤ 2 LEDs), the micro:bit emits an audible alert.





