Shop OBEX P1 Docs P2 Docs Learn Events
Simply turning on an LED — Parallax Forums

Simply turning on an LED

PeriannePerianne Posts: 4
edited 2013-05-31 20:24 in General Discussion
Hi. I am new to basic stamp.

I bought a basic stamp and a 32213 motion detector. I used the program with the motion detector. Everything works fine. It detects motion like it should.

I then added a new line or two to turn on an LED when motion was detected. It did as I programmed, except the LED flashed. To make a long story shorter, I cannot get an LED to stay on.

So, I simplified the program to ONLY turn on an LED. Still, it flashes. I am soooo frustrated after working with this for days, looking on the internet for any solution. Finally, I come here. I have attached photos of the program and the board.

I know this is probably very simple, but I don't know where else to turn. Please help me in this very basic program.


Program.jpg



Board.jpg
448 x 181 - 34K
1024 x 990 - 144K

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2013-05-31 11:06
    The problem you're running into is that your program turns on the LED and immediately quits (by executing the END or by running off the end of the program). What's not obvious at first glance at the programming guides is that the Stamp, when a program ends, goes into a low power mode where the I/O pins get put back into INPUT mode. Periodically the Stamp "wakes up" again, looks around, sets the I/O pins back to how they were, sees nothing is happening, and goes back to sleep again. This is described in the chapter on the END statement in the Basic Stamp Syntax and Reference Manual.

    The way to prevent this is to have your program hang in a loop at the end. Use "DO : LOOP" before the END statement. If you just want to see the LED light for 10 seconds, put a "PAUSE 10000" before the END statement.
  • PeriannePerianne Posts: 4
    edited 2013-05-31 12:10
    Thank you, Mike, for replying.

    My program was indeed in "sleep mode". I had cut the program down too much.

    Anyway, when I put in the DO LOOP. It still flashes, though now at a regular rate. And, the "running" LED on the board stays lit. I also tried the "PAUSE 10000" and it keeps the "running" LED on, but the LED still flashes at a regular rate.

    Thank you for your help.
  • Mike GreenMike Green Posts: 23,101
    edited 2013-05-31 12:27
    Maybe you have an LED with a built-in hardware flasher? Usually they blink at a 1Hz rate. In any event, try a completely different LED.
  • Ken GraceyKen Gracey Posts: 7,392
    edited 2013-05-31 12:34
    Perianne wrote: »
    Thank you, Mike, for replying.

    My program was indeed in "sleep mode". I had cut the program down too much.

    Anyway, when I put in the DO LOOP. It still flashes, though now at a regular rate. And, the "running" LED on the board stays lit. I also tried the "PAUSE 10000" and it keeps the "running" LED on, but the LED still flashes at a regular rate.

    Thank you for your help.

    I didn't see it in the above discussion, but LOW 0 will turn the LED off. Put a PAUSE 10000 after that to see it stay off for ten seconds.

    More importantly, welcome to the forums! All questions are answered!
  • PeriannePerianne Posts: 4
    edited 2013-05-31 13:01
    Ken Gracey wrote: »
    I didn't see it in the above discussion, but LOW 0 will turn the LED off. Put a PAUSE 10000 after that to see it stay off for ten seconds.

    More importantly, welcome to the forums! All questions are answered!

    Thank you, Ken, for replying. Turning the LED off is not a problem. But, I did find (with help) the solution. See below.
  • PeriannePerianne Posts: 4
    edited 2013-05-31 13:04
    Mike Green wrote: »
    Maybe you have an LED with a built-in hardware flasher? Usually they blink at a 1Hz rate. In any event, try a completely different LED.

    Again, Mike, thanks. I did not have another LED, but I put my multimeter on the I/O port and found it to be steady 5V. Thanks to your advice, I pulled the package the LED came in and right on the package it says "Blinking". I have never heard of a self-blinking LED, lol. I think I have been away from electronics too long (about 10 years). Anyway, the circuit - and all of them that I programmed - have been working. It was just the crazy blinking LED. That, and the "sleep mode" have solved my problems.

    I thank you for your help and feel silly.

    Peri
  • TtailspinTtailspin Posts: 1,326
    edited 2013-05-31 20:24
    Don't think yourself as 'silly', Think of it as 'experienced'...
    TIP125_explode.jpg

    :smile:

    -Tommy
    455 x 651 - 246K
Sign In or Register to comment.