Shop OBEX P1 Docs P2 Docs Learn Events
Help with 3 ping sensors — Parallax Forums

Help with 3 ping sensors

RobeRobe Posts: 13
edited 2005-07-06 12:51 in BASIC Stamp
{$STAMP BS2}
{$PBASIC 2.5}
······································· '· I Have written this code for 3 pings to
pingL1····· pin 5·······················navigate,but it seems like I am
pingL2····· pin 2······················ triggering all of them at the same time.
pingCF·····pin 15······················ Also I think my program is to long can
·············································can·anyone·help··················································
triggerL1· con 5······················· me with this program
triggerL2· con 5····················· I would greatly appreciate any help
triggerCF· con 5

scaleL1· con· $200
scaleL2· con· $200
scaleCF· con· $200

rawtoinL1· con·· 889
rawtoinL2· con·· 889
rawtoinCF· con·· 889

ishighL1··· con·· 1···················
ishighL2··· con··· 1
ishighCF··· con··· 1

islowL1···· con··· 0
islowL2···· con··· 0
islowCF··· con···· 0

rawdistL1·· var· word
rawdistL2·· var·· word
rawdistCF·· var· word

inchesL1···· var· word
inchesL2···· var··· word
inchesCF···· var··· word

DO

GOSUB·get_sonarL1
gosub· get_sonarL2
gosub·· get_sonarCF

inchesL1 = rawdistL1**rawtoinL1
inchesL2 = rawdistL2**rawtoinL2
inchesCF = rawdistCF**rawtoinCF

pulsout 13, 850
pulsout 12, 650········ ' go forward

if (inchesL1 = 1 or inchesL1 = 5 or inchesL1 = 6) then· '· HELP WITH rolleyes.gif pulsout 13, 850···················································· ' CAN I SHORTEN
Pulsout 12, 700
elseif (inchesL2 = 1) then
pulsout 13, ....
........

endif
loop


get_sonarL1:

"··············· "··

"··············· "
i





·

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-07-06 12:51
    You're not showing your Get_Sonar subroutine and I suspect that's where the problem is since you've got all three Ping sensors on the same trigger pin.· You are using the Ping))) right, not the SRF-04 (which has separate trigger and echo lines).· Either way, you're telling the program that all three devices are connected to same trigger pin, so if you've hooked it up that what, that's what's going to happen.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
Sign In or Register to comment.