- This topic has 1 reply, 2 voices, and was last updated 7 years, 5 months ago by
Joseph.
-
AuthorPosts
-
June 13, 2016 at 9:59 pm #3572
Nusrat
ParticipantHi Folks,
I have just bought the HC-SR04 sensor, and I see that there is a an Input/Output block called ‘Distance T: ( A ) E: ( B )’ which I suspect is related to the distance sensor. Could someone please point me to some documentation on how I might use that with the sensor? If not how else does one go about programming that? Thanks
NusratJune 13, 2016 at 10:08 pm #3574Joseph
KeymasterHi 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:
-
AuthorPosts
- You must be logged in to reply to this topic.