Home 2018 Forums Crumble Support HC-SR04 sensor support Reply To: HC-SR04 sensor support

#3574
Joseph
Keymaster

Hi Nusrat,

You need to connect two pads (e.g. A and B) to echo and trig (marked as E and T) on the sensor. You also need to connect + and – for power. You can then use the distance block to read the distance, making sure that E and T are set appropriately.

I’ve attached a simple program which reads the distance into a variable and sets a Sparkle red if the distance is less than 20cm. You could skip the use of the variable and use the distance block statement directly in the if statement, but the variable allows you to monitor the value while it’s running.

I hope this helps.

Joseph

Attachments:
You must be logged in to view attached files.