help with a LED Bar Graph

I am new to the Arduino and would like some help. In the LED Bar Graph under the Learning part of the website it says (Though this graph uses 10 LEDs, you can use any number by changing the LED count and the pins in the array.) how would I change it so I can use 51 white LEDs and use a push button to move the light up one and a different push button to move it down one and if it is possible to have the first one lit be the middle one. (ps. i'm looking to have each click to turn on a column of 10 LEDs, so the whole array will end up 51 rows by 10 column wide)

The article (http://arduino.cc/en/Tutorial/BarGraph) assumes you have one output pin per LED. The Arduino Mega would have enough pins to control 51 rows but if you want to light 10 LED's with one pin you will need some kind of driver, like a transistor. Ten LEDS will require either a high voltage and a single resistor (LED's in series) or a high current and one resistor per LED (LED's in parallel). Either way it's too much for an Arduino pin to handle alone. An NPN transistor (with a base resistor) can handle the voltage or current.

Have you chosen your 510 LED's? Are they all the same type? Do you know the "forward voltage drop" and "typical current"? Those bits of information will be needed to design the circuit.

here is a link to the data sheet on the leds on what im thinking about working with.

techd:
here is a link to the data sheet on the leds on what im thinking about working with.

Link is missing.

Sorry about forgetting to add it.

would some thing like this work with the Arduino mega.

Arduino.bmp (952 KB)

OK, that's 3.2V 25 mA. Ten in a row would take 32 volts, minimum. Let's use 40V so the current limiting resistor has something to work with. That leave 8V drop for the current limiting resistor. You need a 320 Ohm resistor to let 25mA flow with 8V of pressure (8*0.025). 8 V * 0.025 A is 0.2 Watts so a 1/4 or 1/2 watt resistor should work.

You need transistors that can handle 40V and 25mA. I'm sure Mouser can supply those for about 6 cents each. You need a resistor between the Arduino pin and the Base of the transistor to limit the current draw. Something about 250 Ohms will limit the current to a very safe 20 mA (5 V / 250 Ohm). You can probably just use more 320 Ohm resistors.

Connect the + (anode) end of the string of LED's to +40V. Connect the - (Cathode) end through the 320 Ohm resistor to the Collector of the transistor. Connect the Emitter of the transistor to Ground (shared between the 40V supply and Arduino). The Arduino pin connects through the 250 (or 320) Ohm resistor to the Base of the transistor.

That's 10 LED's, two resistors and one transistor per segment.

Thank you for the help, now I just need to get the parts and play with some code. :slight_smile:

You need transistors that can handle 40V and 25mA.

It also needs to be an NPN transistor, you showed PNP transistors in that circuit. That won't work because you then need 42V on the base to turn it off, so go with a NPN connected the way johnwasser said.

After thinking about it a lot and things coming up that prolonged the wait, I am about to buy the parts, but know I am thinking about using only one or two leds per pin vs the 10 I planed on. This is what I know about the leds they are microtivity IL451 5mm Clear White LED with a Forward Voltage: 3.0-3.2V. what all would I need to change to make it work with fewer leds?

You need a supply voltage of at least 6.5V, a NPN transistor and a current limiting resistor in line with the LEDs and another in the base of the transistor.

techd:
After thinking about it a lot and things coming up that prolonged the wait, I am about to buy the parts, but know I am thinking about using only one or two leds per pin vs the 10 I planed on. This is what I know about the leds they are microtivity IL451 5mm Clear White LED with a Forward Voltage: 3.0-3.2V. what all would I need to change to make it work with fewer leds?

You need a source for cheaper LEDs. This is what I buy:

Have you seen these:

Yeah, those boards aren't cheap but you could use the idea with your own LEDs.

Rotary encoders are far better than buttons as an input device: 12mm rotary encoder for sale | eBay

which one of these do I need to be higher the the load of the leds the Collector- Base Voltage VCBO, Collector- Emitter Voltage VCEO Max, Emitter- Base Voltage VEBO, or Collector-Emitter Saturation Voltage?

And if I want to add or remove leds per row I just need a power source higher the the load of the leds and a resister to take up the rest and a npn that can handle the Vs across it from the source and 5v to trigger it? right?

Basically yes.
Do not worry about the voltage ratings on the transistor. For what you are doing they will all be fine.
The resistor will need to be calculated each time you change the supply and number of LEDs.

fungus:
Have you seen these:

https://www.youtube.com/watch?v=uZ66PkNUgZI

Rotary Encoder LED Ring Breakout Board - Blue - COM-10407 - SparkFun Electronics

Yeah, those boards aren't cheap but you could use the idea with your own LEDs.

Rotary encoders are far better than buttons as an input device: 12mm Rotary Encoder | eBay

Cheaper alternative:

http://www.ebay.com/itm/251243360872

JoeN:

fungus:
Have you seen these:

https://www.youtube.com/watch?v=uZ66PkNUgZI

https://www.sparkfun.com/products/10407

Yeah, those boards aren't cheap but you could use the idea with your own LEDs.

Rotary encoders are far better than buttons as an input device: 12mm Rotary Encoder | eBay

Cheaper alternative:

http://www.ebay.com/itm/251243360872

Personally, I'd rather spend a few more dollars and help TWO American companies stay in business (Sparkfun, Mayhew Labs) than buy directly from some eBay "store" in China.

1ChicagoDave:
Personally, I'd rather spend a few more dollars and help TWO American companies stay in business (Sparkfun, Mayhew Labs) than buy directly from some eBay "store" in China.

The parts' origin is still China.