Ping Sensor-BoE
in Accessories
Hello, I'm working on making the servo motor move with every ping that it hits.
I will be using 3 different ping sensors, I also want them to ping at about 12 cm out, but when i plug in the second one it goes below 2 cm and it stays in theloop and never stops . I need to know a way to get all 3 pings to work, not just 1.
Can you help me?
I will be using 3 different ping sensors, I also want them to ping at about 12 cm out, but when i plug in the second one it goes below 2 cm and it stays in theloop and never stops . I need to know a way to get all 3 pings to work, not just 1.
Can you help me?
Comments
InConstant CON 890
cmDistance VAR Word
inDistance VAR Word
time VAR Word
col VAR Nib
counter VAR Word
reps VAR Nib
DO
PULSOUT 15, 5
PULSIN 15, 1, time
cmDistance = cmConstant ** time
inDistance = inConstant ** time
DEBUG HOME, DEC3 cmDistance, " cm"
DEBUG CR, DEC3 inDistance, " in"
IF (cmDistance < 5) THEN
DEBUG CR, "Clockwise 10 o'clock", CR
FOR counter = 1 TO 150
PULSOUT 14, 1000
PAUSE 20
NEXT
ENDIF
IF (cmDistance < 5) THEN
DEBUG "Clockwise 2 o'clock", CR
FOR counter = 1 TO 150
PULSOUT 14, 500
PAUSE 20
NEXT
ENDIF
LOOP
CmConstant CON 2260 InConstant CON 890 cmDistance VAR Word inDistance VAR Word time VAR Word col VAR Nib counter VAR Word reps VAR Nib DO PULSOUT 15, 5 PULSIN 15, 1, time cmDistance = cmConstant ** time inDistance = inConstant ** time DEBUG HOME, DEC3 cmDistance, " cm" DEBUG CR, DEC3 inDistance, " in" IF (cmDistance < 5) THEN DEBUG CR, "Clockwise 10 o'clock", CR FOR counter = 1 TO 150 PULSOUT 14, 1000 PAUSE 20 NEXT ENDIF PAUSE 50 ' wait for Ping1 pulses to fade away PULSOUT 13, 5 PULSIN 13, 1, time cmDistance = cmConstant ** time inDistance = inConstant ** time DEBUG HOME, DEC3 cmDistance, " cm" DEBUG CR, DEC3 inDistance, " in" IF (cmDistance < 5) THEN DEBUG "Clockwise 2 o'clock", CR FOR counter = 1 TO 150 PULSOUT 14, 500 PAUSE 20 NEXT ENDIF PAUSE 50 ' wait for Ping2 pulses to fade away LOOP