Example usage of a HC-SR04 Ultrasonic Sensor and the BBC Micro:Bit.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
main.cpp

README.md

microbit-ultrasonic

Example usage of a HC-SR04 Ultrasonic Sensor and the BBC Micro:Bit. The example will return the duration in microseconds and then convert this to a valid Inches or Centimeters value.

Change the lines below to match your Ultrasonic Echo and Ping sensor:

Pin 0 on the Micro:Bit to the HC-SR04 Echo Pin

Pin 1 on the Micro:Bot to the HC-SR04 Trigger Pin

Note: The HC-SR04 Ultrasonic Sensor is a 5v device. It needs 5v to operate, not the supplied 3v from the BBC Micro:Bit. You will need an external power source. The Trigger and Echo pin connect to the Micro:Bit.