The Sonar:bit is an ultrasonic module with a 3-5V working voltage. With only one 3-wire(GVS) cable, you save one IO port in Comparison to the normal 4-wire ultrasonic module. The measurement range of the Sonar:bit is 4cm-400cm. It can output a stable and accurate measurement of data with a ±1cm tolerance. You can use this module for occasions such as short-distance measurement, smart cars, robots, micro:bit and arduino teaching, etc..
- Connect sonar:bit to P2 port on sensor:bit
- Connect micro:bit to your computer.
- Once completed, you can see the picture below
ProgrammingClick to open Makecode online editor.
Write your program to assign the returned value of P2 to variable distance and display it on micro:bit screen.