Shop OBEX P1 Docs P2 Docs Learn Events
Can't get LED's to flash — Parallax Forums

Can't get LED's to flash

Dave45Dave45 Posts: 36
edited 2006-01-21 00:45 in BASIC Stamp
·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

Comments

  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-01-17 03:20
    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
  • Dave45Dave45 Posts: 36
    edited 2006-01-17 10:18
    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 BatesBruce Bates Posts: 3,045
    edited 2006-01-17 11:04
    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 SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-01-17 15:45
    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
  • Dave45Dave45 Posts: 36
    edited 2006-01-17 19:56
    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
  • PJAllenPJAllen Banned Posts: 5,065
    edited 2006-01-17 20:20
    How does this one work?· (attached)

    Post Edited (PJ Allen) : 1/17/2006 8:29:57 PM GMT
  • Dave45Dave45 Posts: 36
    edited 2006-01-18 23:48
    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.
  • Dave45Dave45 Posts: 36
    edited 2006-01-20 02:01
    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.
  • Dave45Dave45 Posts: 36
    edited 2006-01-21 00:45
    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.turn.gif
Sign In or Register to comment.