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
is
Code: Select all
mSecTime = (((ReceiveDataBuffer(2) * 256) + ReceiveDataBuffer(3)) * 0.0000004) * 1000
Distance = ((mSecTime * 1000) / 29) / 2
the 29 is to get the distance in cm as the sonic signal move @ 29usec / cm through air at room temperatures
Regards
QMESAR