TINKER PIEDESIGN IN INDIA

Ultrasonic distance HC-SR04 with TinkerPie

Bat-style sonar. Use the 3.3 V HC-SR04P, or a divider on ECHO for the 5 V version.

TypeTiming sensors
Connect toTRIG and ECHO on two pins (or one pin for 3-pin modules)
Givescm (2-400), -1 = no echo
SimulatorYes: a control appears under the simulated board

How to wire it

One or two signal pins on S1-S4 or P10-P13. Studio reads them with precise timing in the board firmware.

Code

In blocks: Accessories category in TinkerPie Studio. As code:

// JavaScript
sensors.ultrasonicCm(Pin.S1, Pin.S2)

// Arduino C++
sensors::ultrasonicCm(Pin::S1, Pin::S2)

Projects with the Ultrasonic distance HC-SR04

Ultrasonic rulerMeasures how far your hand is, in centimetres, with an HC-SR04 sonar.Sensor projectsSmart dustbin lidWave over the bin: a servo opens the lid for two seconds, then closes it.Sensor projects

Similar modules