1

I'd like to power 30+ LEDs, while having a single LED (at random) flicker every 10-15 seconds.

Is this possible to do using an Arduino? I totally new to this so please bear with me.

This is the type of flicker effect I'm hoping to achieve: https://www.youtube.com/watch?v=753-lkao8l0

Many thanks

5
  • Yes, it is. How much money and board space are you willing to throw at it? Commented Jul 22, 2015 at 20:50
  • @IgnacioVazquez-Abrams Preferably <$100. Space isn't an issue.
    – Bataleon
    Commented Jul 22, 2015 at 22:38
  • Do you mean have 29 LEDs on, and the 30th flicker? Or 29 LEDs off, and one flicker (but only one at a time)?
    – Nick Gammon
    Commented Jul 23, 2015 at 3:56
  • @NickGammon Thanks for the extremely detailed reply. I mean 29 LEDs on, while the 30th flickers.
    – Bataleon
    Commented Jul 23, 2015 at 12:25
  • OK, that was what my test did. The code I presented had a rather simple flicker effect, but if you worked through an array of on/off times you could probably have quite complex flickering.
    – Nick Gammon
    Commented Jul 23, 2015 at 20:36

4 Answers 4

1

Yes, it is possible, but it's harder than making one LED light up, and then doing the other 29 the same.

An LED typically draws 20mA, which is within the limit for an Arduino pin (40mA); however, there is also a 200mA limit for all pins together, so you cannot power more than 10 LEDs off the same arduino. Also, the Arduino only has 13 digital pins, and 5 analog pins, a total of 18 pins. This includes 2 pins used for programming your Arduino.

If you want to run lots of LEDs, the easiest way is running it through an external chip. You can buy a pre-made board e.g. https://www.adafruit.com/products/1429 (24 channel, these can be daisy-chained together for more than 24 LEDs).

Alternatively, you can save yourself some money if you can just buy the chip - a DIP chip, or through-hole, will slot directly into a solderless breadboard, and can be soldered onto veroboard later to make your project more permanent.

There are a number of chips that will do the job, you want an "LED PWM driver" chip - for example, the TLC5940. There is a tutorial for this at http://tronixstuff.com/2013/10/21/tutorial-arduino-tlc5940-led-driver-ic/ - PWM just means you can control the brightness of each LED (individually).

If you want to make your project more permanent, you can solder a board of your own - find someone who can solder (your local makerspace/hackspace will be glad to help, I'm sure!) to teach you the basics, don't burn yourself. The easiest way is to use stripboard (aka Veroboard), this also means you can solder the resistors on to the same board (the LEDs too, if you like!). It sounds very intimidating, but it's not hard to learn. You can then buy PWM chips (make sure you get through-hole, aka "DIP" chips - https://en.wikipedia.org/wiki/Dual_in-line_package ) rather than "surface mount" chips. The chips are sensitive to heat, so to start you might want to solder on sockets (see same wiki page), then you can slot the chips in later.

You should consider very carefully your power supply - find out how many milliamps (or amps) it can provide - every (lit) LED will draw 20 milliAmps, and the Arduino is rated for 200mA, so if you want more than 9 LEDs, you will want an external power source, with an appropriate rating - 500mA = 0.5 amp will drive 24 LEDs. In this case, do NOT use the 2.1mm jack on the Arduino to power it; the transformer will overheat.

P.S. - you will be able to control the exact brightness of each LED independently. Also, if you use RGB leds, and use 3 pins on the IC to drive each LED, then you will be able to control the exact colour of each LED too!

Good luck!

1

I've successfully set up a flickering test with 32 LEDs, based on Using a 74HC595 output shift register as a port-expander.

4 x 74HC595 chips and 32 LEDs

Demo of the overall speed (but not the flickering effect): Vimeo - Shift Register Demo with 32 LEDs

That uses 4 x 74HC595, 32 LEDs, and 32 resistors, plus some decoupling capacitors.

Test sketch which does flicker one and leave the rest alone:

#include <SPI.h>
const byte LATCH = 10;
const byte numberOfChips = 4;
byte LEDdata [numberOfChips];  // initial pattern

void refreshLEDs ()
  {
  digitalWrite (LATCH, LOW);
  for (byte i = 0; i < numberOfChips; i++)
    SPI.transfer (LEDdata [i]); 
  digitalWrite (LATCH, HIGH);
  } // end of refreshLEDs

void setup ()
{
  SPI.begin ();
}  // end of setup

void showPattern (unsigned long patt)
  {
  LEDdata [0] = patt & 0xFF;
  LEDdata [1] = (patt >> 8) & 0xFF;
  LEDdata [2] = (patt >> 16) & 0xFF;
  LEDdata [3] = (patt >> 24) & 0xFF;
  refreshLEDs ();
  } // end of showPattern

const int whichFlicker = 12;  // which LED to toggle
unsigned long pattern = 0xFFFFFFFF;  // pattern for other LEDs

void loop ()
{
  pattern ^= 1UL << whichFlicker;
  showPattern (pattern);
  delay (100);
  pattern ^= 1UL << whichFlicker;
  showPattern (pattern);
  delay (20);
}  // end of loop

The flickering is quite fast, but it isn't PWM. If you make the delays lower, the flickering just becomes a duller light, so I think by getting the timing right you could get flickering going fine.

The wiring (in part) is: 74HC595 schematic

The rest is similar. Of course, you need current-limiting resistors for the LEDs (one each).

You can get the 595 chips from eBay for around $US 1.70 for 20 of them. LEDs are cheap. Resistors are cheap.

0

The other answers use other components to achieve more LEDs. Part of an led is its a diode. You can use this property to link 2 LEDs together and use a high or a low signal to light one. This has a limitation that you can't light both at the same time. But with lighting both for 50% of the time with a short time between each cycle will illuminate both of them. ( though obviously not as bright as if they were powered 100% of the time. )

This idea can be extended into a grid to get more LEDs per pin

Though not an ardiuino its the same chip using the technique mentioned here

http://www.nerdkits.com/videos/ledarray2/

0

Here is an example of a project that simultaneously drives 40 individually controllable LEDs directly connected to an ATTINY...

http://ognite.com

The same technique would also work directly connecting LEDs to the Arduino IO pins.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.