HC-SR04 ultrasonic sensor above a Circuit Playground Express board.
The HC-SR04 is an inexpensive distance sensor based on a pair of ultrasonic transducers with a straightforward TTL level interface and a claimed range of 2cm to 4m. Similar sensors are now commonplace with the widespread use of car parking assistance sensors.
The sensor's 5V Echo output cannot be directly connected to the inputs of a board like the Circuit Playground Express (CPX) but some trivial electronics can remedy this incompatibility.
This project demonstrates distance measurement in Microsoft MakeCode inspired by the BBC micro:bit example starting with a very simple program and then showing more features of MakeCode and the Circuit Playground Express (CPX) board.
If you are new to using MakeCode, check out the guide to getting started first.
Thank-you to George and Edward for the loan of their CPX board.
Adafruit now sell the US-100 Ultrasonic Distance Sensor which is directly compatible with 3.3V levels.
This guide was first published on Sep 17, 2018. It was last
updated on Sep 17, 2018.
This page (Overview) was last updated on Dec 11, 2018.
US-100 Ultrasound Sensor
US-100 Ultrasonic Distance Sensor - 3V or 5V Logic. Easier to use alternative, since it does not require output level conversion.