Hi One and all
its been a long time since I posted but sometimes life throws you a curve ball.
Looking at using the sr04 to operate a stop warning to avoid hitting the wall with the car when
parking. I have the unit working and reading in mm but only getting results to the nearest 100mm's (ie 100,200,300 and so forth)
is it possible to breakdown the values to read say 80mm 135mm and such.
Thank you all in advance for your wisdom
its been a long time since I posted but sometimes life throws you a curve ball.
Looking at using the sr04 to operate a stop warning to avoid hitting the wall with the car when
parking. I have the unit working and reading in mm but only getting results to the nearest 100mm's (ie 100,200,300 and so forth)
is it possible to breakdown the values to read say 80mm 135mm and such.
Thank you all in advance for your wisdom
Code:
'Stop the car NOW love using an sr04 trig and echo connected via 2200k resistor
#Picaxe 18M2
#no_data
symbol trig = B.1 ' Define output pin for Trigger pulse
symbol echo = B.1 ' Define input pin for Echo pulse
symbol range = w0
setfreq m4
main:
do
HIGH trig 'output for Trigger pulse
PULSIN echo, 1 ,range ' Measure the duration of the echo pulse
pause 10 ' Recharge period after ranging completes
range = range / 58*100 ' Convert duration to distance in mm
sertxd("distance ",#range," mm",cr,lf) ' Output the distance
sertxd(" bits of w0 ",#bit15,#bit14,#bit13,#bit12,bit11,#bit10,#bit9,#bit8,#bit7,#bit6,#bit5,#bit4,#bit3,bit2,#bit1,bit0,cr,lf)
pause 5000 ' Wait before the next measurement
loop ' Repeat the process