US-016 wiring
The ultrasonic sensor is powered from the expansion board using pins 3V3 and GND . Next, you need to connect the output from the ultrasonic sensor, i.e. pin Out , to the analog input pin of the micro:bit. In this case, we chose pin P2.
MB2
MB3
Connection (TRIG and ECHO)
The ultrasonic sensor is powered from the expansion board using pins 3V3 and GND . It is also necessary to connect a pin for the transmitter (Trig) and receiver (Echo). In the following programs, we use pins P14 – Echo and P15 – Trig.
MB2
MB3
Programmes
The programs again differ according to the type of ultrasonic sensor. They are further divided according to the expansion board used. The MB1 board is equipped with a built-in LED strip, which is great for indicating the distance that the sensor measures.
However, in principle, the programs are the same, they only differ in the use of the Neopixel library for the LED strip.
Sensor US-016
Basic program
Advanced program
This program already works with variable speed. Based on the measured distance, it sets the tank speed to the variable “speed”. By changing the value of the constant DIST_MIN or DIST_MAX, you can adjust the range of measured distances.
Common sensors (TRIG and ECHO)
Basic program
Same function as the program for the MB1 board, only without LED.
Advanced program
Same function as the program for the MB1 board, only without LED.



