Switching LEDs fast

Discussion in 'The Projects Forum' started by DancinNancy, Nov 20, 2008.

  1. DancinNancy

    Thread Starter Member

    Oct 1, 2008
    I have read several times that if you switch LEDs on and off quick enough nobody will be able to tell it is turning off. I want to be able to switch between at least 2, preferably 4, LEDs so that they all look like they are staying on. Does anyone have any example code of something like this that I can go by
  2. mik3

    Senior Member

    Feb 4, 2008
    If you just want to switch 4 leds on/off use a 555 timer to do it. It really works! If you want see my spectrum analyzer on the first link below, all the display works on this effect which is called the effect of persistence of vision.
  3. SgtWookie


    Jul 17, 2007
    That's true, once you get over perhaps 30Hz, persistence of vision makes it difficult to tell that the LED is not on constantly.
    The code is going to be rather hardware-specific. Something written for an Atmel won't run on a Microchip uC.

    Microchip's PICKIT 1 flash starter kit comes with a PIC12F675 programmed to flash 8 LEDs, one at a time (demo.c). I changed it to flash 12 LEDs in selectable patterns. However, the program and header files are copyrighted, so I won't upload it.

    You may be able to download it from the Microchip website.

    There are plenty of examples of code to flash LEDs on sites like Instructibles.com - look for Charlieplexing examples and the like.
  4. KL7AJ

    AAC Fanatic!

    Nov 4, 2008
    We used to use LEDs for calibrating photomultipliers....we could get down to around 10 nS switching times with off the shelf devices.