Go Down

Topic: Common Anode LED array - Individual Addressing (Read 2810 times) previous topic - next topic


Dec 27, 2010, 12:11 am Last Edit: Dec 27, 2010, 12:12 am by NerdyFirefighter Reason: 1
So I purchased some common anode LED bar graphs without realizing it.   I didn't pay attention to the block diagram... lesson learned.


Is there a way with the Arduino to turn the individual LEDs on and off?   I was thinking you could potentially switch the digital pins from input to output on the fly, but this seems like an exceptionally large amount of code for that.

Is there another way (other than say using transistors as switches :( )?

My long-term plan is to buy bar graphs without common anodes or cathodes (although cathodes would be fine).

Here is what I have (doh)...


Its just as easy to drive common anodes as common cathodes, its the difference between active high and active low...  The common pins will probably need driving through a transistor to up the current levels from the 30mA or so that an Arduino pin can source/sink - which is generally enough for one LED.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


Forgive my ignorance, but how do you do this?

My thinking is that I could drive the anode from the +5V and then each cathode to a digital pin, then switch them either from high to low or from read to write... is this how it would be done?   Is there some other aspect of the pins I'm missing here?

I know from tinkering that the +5V on my Nano is enough to drive all 10 LEDs at the same time without causing a reset... I've also tested it with the examples for fading and blinking from pin 9 and pin 13.


Dec 27, 2010, 05:52 am Last Edit: Dec 27, 2010, 05:54 am by CrossRoads Reason: 1
Hey man, still working on the temperature warning system?
I would do it like this, maybe not necessarily with arduino pins on the cathode, maybe with shift register pins, I don't recall how many pins you had committed with the temperature sensor.
Anyway the idea would be that you multiplex the  LEDs - if you wanted 5 green bars, you drive the green anode high then quickly cycle thru the 5 green cathodes one at a time in a continuous loop, with enough duration and at a speed fast enough that they all look on. Maybe set the loop to go thru all 10 all time, and just not turn on the higher ones unless needed to make the intensity the same all the time.
Once the heat started getting up there, you turn off the green anode and turn on the orange anode and start doing the same thing, with more & more as the heat increased.

No matter how you do it, make sure to only turn on on LED at a time to avoid overloading an anode output.
If you are allowing size to increase, then you could consider adding 2 transistors to control sourcing current from Vcc and two SN7406s, which are 6 inverting drivers in a 14 pin package which can sink 40mA each (still thinking just one Anode on at a time), high output from arduino is inverted and turns on the LED with high Anode.
Conveniently packaged, yet will need min of 4.5V to work.  I don't recall what your temp. guage ran at if you were considereng running the competed package from a 3.7V LiPO battery.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


Thanks for the help CrossRoads yet again.

I do have a question on something to add here...

In my tinkering to try and figure this out I put the LED graph on my breadboard with the cathodes being tied to pins 2-11 and I clipped the red anode off the package so that the green could sit in the + rail of the board.   I realize this is bad because I don't have a limiting resistor between but if I run resistors in front of everything, is this bad?

For example...

+5V ----> 2x 220R (just what I had handy)---->10 LEDs---->Pins 2-11

When I ran the BarGraph tutorial example unedited (except for the mapping window for my inputs) I generally get the result I want (identical to the videos I've made).

Am I just pushing too much juice through the LEDs?   As a test I cycled my RTD up and down in temp for about 12 hours last night with no burn outs, magic smoke, stink, or otherwise... Am I playing Russian Roulette here or am I just going to shorten the lifespan of the LEDs or Arduino by some unknown amount?

Also, is the +5V regulated to stay there?   I ask because I'm definitely running 10 LEDs, 440R, AND the voltage divider (4000R)... which the LEDs are presumably screwing with my voltage through the RTD changing the actual values... right!?

:D  :P


That approach, with 1 effective current limiting resistor of 110 ohm (if I read your post correctly that you had two 220 ohm resistors in parallel to just 1 common anode, the other having been removed), if there were no LEDs and the resister just went ground, the max current could be 5/110 = 45mA.
Now you are sharing that 45mA across 10 LEDs which are not at ground.  You would theoretically see changing brightness as you changed the # of LEDs that were on.
With just 1 LED, the current drops some as the LED would have 2.2V across it, so the max current it would see is (5-2.2)/110 = 25mA, which is within the bounds of all the specs you have shown.

If you are not noticing the changing brightness, then I think you'd be fine.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.


The resistors are actually in series (total 440R).

There is a dimming effect as they come on... but given that this will be sitting mere inches from your eyeball... it works, lol.


That is a good reason to multiplex the lights then. Maybe have the lights turn on in sequence, blink at the highest one a few times, then turn off and start again:
1-2-3-4-5, 5, 5, 5
1-2-3-4 5, 5, 5, 5
then as the heat increased, start in with the orange:
1,  1,  1, then
1- 2- 3, 3, 3, 3
1- 2- 3, 3, 3, 3
and increasing in  the # of LEDs and in blink rate as the temp went up

You'd have to try it, see if it was too distracting, annoying, etc.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up