Page 1 of 1

Ping Sensor

Posted: Tue Jul 28, 2015 10:13 am
by willow
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>
----------------------------------------

Re: Ping Sensor

Posted: Tue Jul 28, 2015 1:14 pm
by medelec35
Hi willow,
Perhaps a starting point would be this whole thread
If you do try the flowchart and get stuck then let us know.

Martin

Re: Ping Sensor

Posted: Tue Jul 28, 2015 2:05 pm
by willow
Hi
The sensor is working ok with the arduino ping sketch example ,but it seem's more difficult to make it work on the flowcode 6 software ,the distance I'm working with is about 30-150mm max.
regards