Shop OBEX P1 Docs P2 Docs Learn Events
Blinking Led, beginners question — Parallax Forums

Blinking Led, beginners question

ArchiverArchiver Posts: 46,084
edited 2001-07-25 01:34 in General Discussion
Peter-

If you literally mean you want an LED to blink (or not) while other
things are going on, use a blinking LED. They're commonly available
and allow your program to take care of other business.

Regards,

Steve

On 24 Jul 01 at 20:06, daliti wrote:

> If I want to blink a led slowly, then i have to insert anyway a long
> Pause time (i think). This also means that the program stops on that
> moment. How can I prevent the program stops - say I want to measure
> a high frequency pulse while "led-blinking" - and the led needs to
> keep blinking? Thanks for your help.

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-07-24 21:06
    If I want to blink a led slowly, then i have to insert anyway a long
    Pause time (i think). This also means that the program stops on that
    moment. How can I prevent the program stops - say I want to measure a
    high frequency pulse while "led-blinking" - and the led needs to keep
    blinking?
    Thanks for your help.
  • ArchiverArchiver Posts: 46,084
    edited 2001-07-24 21:10
    Just completing my question: I suppose while the programs stops in
    the puase time, there is no possibility to do anything else then
    waiting till the pause time is counted down.
    Thanks
    Tim, Belgium.
  • ArchiverArchiver Posts: 46,084
    edited 2001-07-24 21:59
    You can use a 555 timer to do this. There's actually a circuit diagram in
    one of the stampsinclass documents.


    On Tue, 24 Jul 2001, daliti wrote:

    > If I want to blink a led slowly, then i have to insert anyway a long
    > Pause time (i think). This also means that the program stops on that
    > moment. How can I prevent the program stops - say I want to measure a
    > high frequency pulse while "led-blinking" - and the led needs to keep
    > blinking?
    > Thanks for your help.
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and Body
    of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
    >

    Sean T. Lamont, CTO / Chief NetNerd, Abstract Software, Inc. (ServNet)
    Seattle - Bellingham - Vancouver - Portland - Everett - Tacoma - Bremerton
    email: lamont@a... WWW: http://www.serv.net
    "...There's no moral, it's just a lot of stuff that happens". - H. Simpson
  • ArchiverArchiver Posts: 46,084
    edited 2001-07-24 22:14
    At 16:06 07/24/01, daliti wrote:
    >If I want to blink a led slowly, then i have to insert anyway a long
    >Pause time (i think). This also means that the program stops on that
    >moment. How can I prevent the program stops - say I want to measure a
    >high frequency pulse while "led-blinking" - and the led needs to keep
    >blinking?

    Arrange your program steps something like this:

    Turn on LED
    Measure high frequency pulse
    do other stuff if you want to
    pause (LED on time)
    turn LED off
    do more stuff
    pause (LED off time)
    go back to top of program

    The Stamp can do an incredible number of things during the LED on and LED
    off times. The whole on or off time doesn't have to be a useless pause.

    Jim H
  • ArchiverArchiver Posts: 46,084
    edited 2001-07-24 22:30
    In a message dated 7/24/01 3:20:51 PM Central Daylight Time,
    peter.christiaen@s... writes:


    > If I want to blink a led slowly, then i have to insert anyway a long
    > Pause time (i think). This also means that the program stops on that
    > moment. How can I prevent the program stops - say I want to measure a
    > high frequency pulse while "led-blinking" - and the led needs to keep
    >

    This is a little advanced, but can be done. What you need to do is create a
    timer variable in your main program loop. At the end of the main loop (after
    you've done your frequency measurement), you increment your timer then take
    the modulus of some value (the larger this value, the slower your LED will
    blink). If the result is zero, toggle the LED. Like this:

    MyLED CON 0
    MaxTimer CON 500

    timer VAR Word

    Init:
    LOW MyLED

    Main:
    ' do frequency measurement here
    timer = timer + 1 // MaxTimer
    IF (timer > 0) THEN Main
    TOGGLE MyLED
    GOTO Main

    When this program runs it will take 500 frequency measurements before
    toggling the LED. As your program grows, the LED blink timing will change so
    you'll need to adjust the value of MaxTimer accordingly.

    -- Jon Williams
    -- Applications Engineer, Parallax




    [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2001-07-24 22:45
    Hi Tim,
    You might blink the led, and sense for the high frequency pulse
    within a "loop" that you would do for "x" number of times, each
    with a very short pause time. The net effect would be that you
    would be blinking and sampling immediately following each blink.
    An "If/then" within the loop could then take the program elsewhere
    if a particular condition was reached.

    Russ


    Original Message
    From: daliti <peter.christiaen@s...>
    To: <basicstamps@yahoogroups.com>
    Sent: Tuesday, July 24, 2001 4:10 PM
    Subject: [noparse][[/noparse]basicstamps] Blinking Led, beginners question


    | Just completing my question: I suppose while the programs stops in
    | the puase time, there is no possibility to do anything else then
    | waiting till the pause time is counted down.
    | Thanks
    | Tim, Belgium.
    |
    |
    | To UNSUBSCRIBE, just send mail to:
    | basicstamps-unsubscribe@yahoogroups.com
    | from the same email address that you subscribed. Text in the Subject and Body
    of the message will be ignored.
    |
    |
    | Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    |
    |
  • ArchiverArchiver Posts: 46,084
    edited 2001-07-25 01:02
    Why not just toggle the pin, so the light goes on and off each time the
    program loop is executed.

    Original Message


    > Just completing my question: I suppose while the programs stops in
    > the puase time, there is no possibility to do anything else then
    > waiting till the pause time is counted down.
  • ArchiverArchiver Posts: 46,084
    edited 2001-07-25 01:34
    That's possible to do, but the timing gets weird because you have to
    calculate the timing of everything that you do inside the loop to get an
    accurate blink interval ; the 555 timer will do this for you in a separate
    IC.

    On Tue, 24 Jul 2001, Rodent wrote:

    > Why not just toggle the pin, so the light goes on and off each time the
    > program loop is executed.
    >
    >
    Original Message
    >
    >
    > > Just completing my question: I suppose while the programs stops in
    > > the puase time, there is no possibility to do anything else then
    > > waiting till the pause time is counted down.
    >
    >
    >
    >
    >
    > To UNSUBSCRIBE, just send mail to:
    > basicstamps-unsubscribe@yahoogroups.com
    > from the same email address that you subscribed. Text in the Subject and Body
    of the message will be ignored.
    >
    >
    > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    >
    >
    >

    Sean T. Lamont, CTO / Chief NetNerd, Abstract Software, Inc. (ServNet)
    Seattle - Bellingham - Vancouver - Portland - Everett - Tacoma - Bremerton
    email: lamont@a... WWW: http://www.serv.net
    "...There's no moral, it's just a lot of stuff that happens". - H. Simpson
Sign In or Register to comment.