Dave45
01-17-2006, 09:12 AM
·I'm doing Robotics with the Boe-Bot. I'm on page 254 your turn at the bottom of the page where they want you to flash the led's when the·Ir detects something. I can't figure out how to get it to work. I thought the commands below in the program would work, but they don't. The led's flash when i just run a program to flash them. In this program they wont flash. I've got the right I/O pins and everything else is right I think. Guess not though, it doesn't work.·Can someone tell me what i'm doing wrong? I'm just trying to flash them when both IR's detect something in the program below. Thanks.
'Robotics wiht the Boe-Bot - FasrIrRoamingYourTurn.bs2
'Higher performance IR object detection assisted navigation.
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
irdetectleft····· VAR···· Bit
irdetectright···· VAR···· Bit
pulseleft········ VAR···· Word
pulseright······· VAR···· Word
counter·········· VAR···· Word
FREQOUT 4, 2000, 3000
'---------------------------'Main Routine-------------------------------------------------
· FREQOUT 8, 1, 38500·· ' Check It detectors
· irdetectleft = IN9
· FREQOUT 2, 1, 38500
· irdetectright = IN0
DO
· IF (irdetectleft = 0) AND (irdetectright = 0) THEN········· 'Decide how to navigate
··· HIGH 10
··· HIGH 1
··· PAUSE 500
··· LOW 10
··· LOW 1
··· pulseleft = 650
··· pulseright = 820
· ELSEIF (irdetectleft = 0) THEN
··· pulseleft = 850
··· pulseright = 850
· ELSEIF (irdetectright = 0) THEN
··· pulseleft = 650
··· pulseright = 650
· ELSE
··· pulseleft = 850
··· pulseright = 620
· ENDIF
·
PULSOUT 13, pulseleft··········· 'Apply the pulse
· PULSOUT 12, pulseright
· PAUSE 15
LOOP··········································· 'Repeat main routine
'Robotics wiht the Boe-Bot - FasrIrRoamingYourTurn.bs2
'Higher performance IR object detection assisted navigation.
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
irdetectleft····· VAR···· Bit
irdetectright···· VAR···· Bit
pulseleft········ VAR···· Word
pulseright······· VAR···· Word
counter·········· VAR···· Word
FREQOUT 4, 2000, 3000
'---------------------------'Main Routine-------------------------------------------------
· FREQOUT 8, 1, 38500·· ' Check It detectors
· irdetectleft = IN9
· FREQOUT 2, 1, 38500
· irdetectright = IN0
DO
· IF (irdetectleft = 0) AND (irdetectright = 0) THEN········· 'Decide how to navigate
··· HIGH 10
··· HIGH 1
··· PAUSE 500
··· LOW 10
··· LOW 1
··· pulseleft = 650
··· pulseright = 820
· ELSEIF (irdetectleft = 0) THEN
··· pulseleft = 850
··· pulseright = 850
· ELSEIF (irdetectright = 0) THEN
··· pulseleft = 650
··· pulseright = 650
· ELSE
··· pulseleft = 850
··· pulseright = 620
· ENDIF
·
PULSOUT 13, pulseleft··········· 'Apply the pulse
· PULSOUT 12, pulseright
· PAUSE 15
LOOP··········································· 'Repeat main routine