+ Reply to Thread
Results 1 to 1 of 1

Thread: LED Flasher

  1. #1

    Default LED Flasher

    Here's a little program for flashing LEDs.

    I'm pretty sure there has got to be a bunch of programs like this already on the forum.

    Here's my interpretation of a program to flash multiple LEDs at multiple rates.

    This object allows any (and all) Propeller pins to be used to flash LEDs.

    The object uses one cog to flash the LEDs.

    After the object has been started with a call to the Start method, a LED can be flashed by calling the method "AddLed".

    Here's the documentation on the "AddLed" method.

    PUB AddLed(pin, onMs_, offMs_, count_)
    '' onMs_ is the time the LED is to be on each flash.
    '' onMs_ is limited to 26,843ms (over 26 seconds).
    '' offMs_ is the time LED will be off between flashes.
    '' offMs_ has the same limit as onMs_.
    '' count_ is the number of times to flash the LED.
    '' If count_ is set to zero then the LED will continue
    '' to flash indefinitely.
    '' The Start method must be called prior to calling this
    '' method.
    '' This method returns the active state
    '' of the pin prior to calling this method or a -1 if the
    '' pin number was out of range.
    Each LED can have different values for each of the arguments. All 32 pins can be used to flash the LEDs.

    As an example, if you wanted to flash a LED on pin 8, ten times, at 2Hz, you'd call AddLed with these arguments.

      Led.AddLed(8, 250, 250, 10)
    This will turn the LED on for 250ms and off for 250ms giving it a period of 500ms (2Hz). It wouldn't be hard to add a method to change frequency to on and off times. For example, the firmware for Eddie uses a frequency parameter in units of 0.1Hz. To change from units of tenths of a Hertz to milliseconds on and off use: (milliseconds on or off) = 5000 / (frequency in tenths of a Hertz). So 10Hz would be 5000/100 = 50ms on and 50ms off.

    The attached demo takes input from a serial terminal to flash the LEDs on the QuickStart board. When a number 0 through 7 is pressed on the keyboard, a LED on the QuickStart board will flash 20 times at 1Hz.

    Edit(3/11/15): Warning, the code attached is an old version. There are likely better options available.
    I plan to upload this program or an improved version to my GitHub account
    If there isn't code similar to what is attached here on my on GitHub, send me a message and I'll make and check for any improved versions of the code.

    Additional note. This object has a severe bug. I encourage anyone interested to look for an updated version in my GitHub account.
    Last edited by Duane Degn; 03-11-2015 at 08:47 PM.

+ Reply to Thread

Similar Threads

  1. [completed] Flasher Dasher
    By doggiedoc in forum Projects
    Replies: 12
    Last Post: 03-31-2011, 03:56 AM
  2. Dual color LED flasher - complete
    By Capdiamont in forum SX Chips and Programming Tools
    Replies: 3
    Last Post: 10-21-2008, 08:50 AM
  3. Problems with CMOS and TTL LED flasher circuits from Forrest M. Mims III
    By bryan mcdonald in forum General Discussion
    Replies: 8
    Last Post: 05-28-2008, 08:45 PM
  4. CW Flasher
    By n1iic in forum BASIC Stamp
    Replies: 11
    Last Post: 07-20-2005, 04:10 AM


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts