Hi, I've gotten one SRF05 sensor working and giving an LED output, however, I can't seem to work out a code which allows two SRF05 to input and each one turning on a single LED. Any help, please? I am using two SRF05 ultrasonic sensor and an 18M2 Protoboard.
Here is my code for one sensor:
symbol trig1 = B.3 'Define output pin for Trigger pulse
symbol echo1 = C.6 'Define input pin for Echo pulse
symbol range1 = w1 '16 bit word variable for range
rightled:
high 2
pause 1
goto main
main:
low 0
low 1
low 2
pulsout trig,2 'produces 20uS trigger pulse (must be minimum of 10uS)
pulsin echo,1,range 'measures the range in 10uS steps
pause 10 'SRF004 mandatory 10mS recharge period after ranging completes
'now convert to cm (divide by 6.2) or inches (divide by 14.9)
'as picaxe cannot use 6.2, multiply by 10 then divide by 62 instead
let range = range*10/62 'multiply by 10 then divide by 62
if range>40 then main
if w1>0 then leftled
debug range
goto main
Here is my code for one sensor:
symbol trig1 = B.3 'Define output pin for Trigger pulse
symbol echo1 = C.6 'Define input pin for Echo pulse
symbol range1 = w1 '16 bit word variable for range
rightled:
high 2
pause 1
goto main
main:
low 0
low 1
low 2
pulsout trig,2 'produces 20uS trigger pulse (must be minimum of 10uS)
pulsin echo,1,range 'measures the range in 10uS steps
pause 10 'SRF004 mandatory 10mS recharge period after ranging completes
'now convert to cm (divide by 6.2) or inches (divide by 14.9)
'as picaxe cannot use 6.2, multiply by 10 then divide by 62 instead
let range = range*10/62 'multiply by 10 then divide by 62
if range>40 then main
if w1>0 then leftled
debug range
goto main
Attachments

931 bytes Views: 6