Search code examples
timerarduinoled

What is the most efficient way to time LED’s


I need to create a board that will contain about 50 LED’s. The LED’s need to be turned on/off individually, and together (timer is based on days suppose every Monday all the 50 LED’s turn on and every day of the week 10 LED’s are turned on).

In my research I have found the LM555 timer but that would lead to a huge circuit of 50 different timers

What is the most efficient way of controlling these LED’s


Solution

  • My first answer was really stupid (i'm so sorry about that) and i don't know why I didn't think before about the amazing "Shift Registers".

    Your Arduino don't have so much pin to light every LEDs you had. But using shift registers this is possible. From an 8-bit shift register you can light 8 LEDs using just 2-3 PIN on your Arduino board (1 for clock, 1 for data and 1 for latch). So to light 50 PINs you just need 7 of this components (for example).

    How to use it? There are a lot of tutorials on internet, usually the sparkFun tutorial is my favorite.

    Below: an image from Arduino site. It explained how to connect 16 LEDs. connect 16 leds with 2 shift registers

    Anyway from the software side, what you have to know ShiftOut function. After that you have to use time function.

    First of all initialize your time variables as you can see in link I posted above. After, in your loop:

    • Put HIGH your Datapin connected to 50 leds when previousMonth != month.
    • Put HIGH dataPin connected to 10 leds when daySum == 10 (so, when previousDay != day you have to increase daySum using daySum++).