Ping Sensor
Posted: Tue Jul 28, 2015 10:13 am
hi can anyone help with the configeration of the a hc-sr04 ultrasonic sensor as the example code I've adpted will only give me 17 or 0 output through a serial port.
Please see Below :
----------------------------------------
Comment:
This example program is configured to measure approximately 1.5-2m (150 - 200cm) from the sensor.
If much shorter distances are used, parameters will need to be changed.
----------------------------------------
----------------------------------------
Call Component Macro:
----------------------------------------
----------------------------------------
Call Component Macro:
----------------------------------------
----------------------------------------
Call Component Macro:
----------------------------------------
----------------------------------------
Call Component Macro:
----------------------------------------
----------------------------------------
Loop:
1
<LOOP>
----------------------------------------
Call Component Macro:
----------------------------------------
----------------------------------------
Allows the potentiometer to be used to set the threshold level:
sense = sense / 20
----------------------------------------
----------------------------------------
Call Component Macro:
----------------------------------------
----------------------------------------
Delay:
100 ms
----------------------------------------
----------------------------------------
Call Component Macro:
----------------------------------------
----------------------------------------
Calculation:
dist = ToString$ (distance)
sens = ToString$ (sense)
----------------------------------------
----------------------------------------
Call Component Macro:
----------------------------------------
----------------------------------------
Call Component Macro:
----------------------------------------
----------------------------------------
Call Component Macro:
----------------------------------------
----------------------------------------
Call Component Macro:
----------------------------------------
</LOOP>
----------------------------------------
Please see Below :
----------------------------------------
Comment:
This example program is configured to measure approximately 1.5-2m (150 - 200cm) from the sensor.
If much shorter distances are used, parameters will need to be changed.
----------------------------------------
----------------------------------------
Call Component Macro:
----------------------------------------
----------------------------------------
Call Component Macro:
----------------------------------------
----------------------------------------
Call Component Macro:
----------------------------------------
----------------------------------------
Call Component Macro:
----------------------------------------
----------------------------------------
Loop:
1
<LOOP>
----------------------------------------
Call Component Macro:
----------------------------------------
----------------------------------------
Allows the potentiometer to be used to set the threshold level:
sense = sense / 20
----------------------------------------
----------------------------------------
Call Component Macro:
----------------------------------------
----------------------------------------
Delay:
100 ms
----------------------------------------
----------------------------------------
Call Component Macro:
----------------------------------------
----------------------------------------
Calculation:
dist = ToString$ (distance)
sens = ToString$ (sense)
----------------------------------------
----------------------------------------
Call Component Macro:
----------------------------------------
----------------------------------------
Call Component Macro:
----------------------------------------
----------------------------------------
Call Component Macro:
----------------------------------------
----------------------------------------
Call Component Macro:
----------------------------------------
</LOOP>
----------------------------------------