Project to read the Paralax Ultrasonic sensor

A forum where Flowcode v6 user created components can be shared, discussed and reviewed.

Moderator: Benj

User avatar
Valued Contributor
Valued Contributor
Posts: 1068
Joined: Sun Oct 05, 2014 3:20 pm
Has thanked: 330 times
Been thanked: 537 times

Project to read the Paralax Ultrasonic sensor

Postby QMESAR » Sat Nov 15, 2014 8:28 pm

Hi All
As before as I am working my way through FC ,I also thought that this might help some one who wish to work with the Parallax Ultrasonic sensor to read distance to objects
the code outputs the Timer cycle Time over serial ,you can easily read the data into a PC GUI and the formula to calculate the distance from the Timer time

Code: Select all

 mSecTime = (((ReceiveDataBuffer(2) * 256) + ReceiveDataBuffer(3)) * 0.0000004) * 1000
          Distance = ((mSecTime * 1000) / 29) / 2

The measured Time is the round trip time of the sonic signal there fore to get the distance we need to divide by two to get the singel time from the object back to the sensor
the 29 is to get the distance in cm as the sonic signal move @ 29usec / cm through air at room temperatures

Parallax UltraSonic
(201.47 KiB) Downloaded 205 times
my PC application view
15.11.png (34.47 KiB) Viewed 2570 times
These users thanked the author QMESAR for the post (total 2):
medelec35 (Sat Nov 15, 2014 10:08 pm) • Benj (Mon Nov 17, 2014 11:12 am)
Rating: 11.76%