PDA

View Full Version : Can't get LED's to flash



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

Bruce Bates
01-17-2006, 10:20 AM
Dave -

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

Dave45
01-17-2006, 05:18 PM
The program is took right out of the Robotics for the Boe-Bot book. Chapter 7, page 252 and page 253. The only thing I have added is the high and low commands for pin 10 and 1.· The wiring is right out of the book, and it is correct. The program TestIrPairsAndIndicators.bs2 on page 243 works fine. This means the wiring is correct. I just don't understand why the high and low commands i entered don't flash the led's. Thanks.

Bruce Bates
01-17-2006, 06:04 PM
Dave -

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
01-17-2006, 10:45 PM
Perhaps you should run the IR sensor test again.· Maybe one of your sensors isn't functioning correctly so the program isn't seeing both IR sensos active at once.

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com (mailto:csavage@parallax.com)

Dave45
01-18-2006, 02:56 AM
I ran the Ir test again, it works fine. I put my hand in front of both sensors and the led's blink once. The program is TestIrPairsAndDetectors.bs2 . But it still doesn't make the led's light in the program I posted. I appreciate your reply's. Thanks

PJ Allen
01-18-2006, 03:20 AM
How does this one work?· (attached)

Post Edited (PJ Allen) : 1/17/2006 8:29:57 PM GMT

Dave45
01-19-2006, 06:48 AM
With help I've been able to get the left one to light occasionally. I was told it's a timing issue. Still working on it. Thanks for all the replys.

Dave45
01-20-2006, 09:01 AM
I just ran chapter 7 project 3 program that came right out of the book and the LEDS still don't flash. They flash fine on the led test program. Code follows for chapter 7 project 3 program.

Dave45
01-21-2006, 07:45 AM
I figured out the problem with the help of parallax. It was their idea to check the wiring that fixed it. I had everything wired the correct way, but their suggestion made me try things that i didn't think could be the problem. Which led me to replace the leds with other ones. Once I replaced the leds it worked the way it was suppose to. The leds flashed. The weird thing is the other leds would flash running a test program for them. They just failed to work in a program that was doing more than just checking leds. I have no idea why that would be, any ideas? Thanks everyone.http://forums.parallax.com/images/smilies/turn.gif