Can't get LED's to flash
Dave45
Posts: 36
·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
Comments
Since NONE of your I/O pin ports have definitive, descriptive labels it's just a guess as to which pin ports you're using for anything, much less the LED's. An educated guess is that pin ports 1 and 10 are being used for the LED's. If that's the case, how do you have them wired?
Just as a matter of information LED's ARE polarity sensitive, and if installed backwards, they will not light.
Before you go too much further in your programming efforts, you may want to take a moment out to read Jon Williams excellent piece on "The Elements of PBASIC Style" which can be downloaded from here (12th line down):
http://www.parallax.com/html_pages/downloads/basicstamps/documentation_basic_stamp.asp
Regards,
Bruce Bates
Maybe we're dealing with semantics here. HIGH will turn the LED ON if it is wired properly. LOW will turn the LED OFF if it is wired properly. To the extent that it goes ON then OFF, I suppose that's flashing. If you want more repetition - ON - OFF - ON - OFF - ON - OFF, etc then the HIGH then LOW sequence will need to be in a loop with an appropriate PAUSE statement. Perhaps that's what you were seeking?
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
Post Edited (PJ Allen) : 1/17/2006 8:29:57 PM GMT