Lots of little lights

I just got an Arduino Mega 2560 and I want to build my first, and extremely basic, midi controller with it. Just 16 rotary pots with the analog ins, and then I want to use the digital ports for LED back lighting. Please excuse me for knowing so little about circuits, electricity, and electronics in general; I am very new to this. How many LEDs can I power with one digital out on the Arduino? Would I need to use resistors for each LED on a single output? I've got 50 outs, and I want to use as many lights as possible, but I do not want to cause any damage of course. What about the pwm's? I understand how these work, I've done some very basic led dimming/blinking with them. Can they handle more or less then the other digital outs? Also, I am planning to use Max for Live to convert the serial to midi in ableton, and then simply assigning the knobs to various parameters. Will the Mega be able to handle 16 analog pots and all 50 digital ports controlling LEDs? All insight is thoroughly appreciated!

So many questions in one post.
Yes, a Mega can do whatever you can dream up. It might just need a little external help to do that.
Please explain what YOU think a MIDI controller has to do, because to me it's rather vague.
And yes, a Mega can control as many LEDs as you want. Thousands of them. Maybe more.
But not the way you describe it.
Every output can drive a LED with a series resistor, but there is a limit to the total current the Mega can handle.
Better to use e.g. a digital RGB LED strip. The whole strip can be controlled by just one or two output pins.

Leo..

Thanks Wawa,
I figured I'd hammer all my questions out at once. It am not building an actual midi controller in the sense that it will not actually use midi data or ports. I just use that term vaguely. I have seen people use Max to pick up the serial reads from an Arduino, and use them to control things like volume and panning in Ableton. So all I want is to set up 16 knobs in a box, and use them to control my music software. I've looked at the LED strips on Adafruit, but it looks like they all need an external plug, and I'd like to keep it to just the usb and the 5v that is on the Arduino, so that I do not have a box that requires multiple plugs.

Instead of using the term MIDI (which, technically , is the name of a music instrument communications protocol), why don’t you just tell us what your final objective is.

Project Objective

My objective is to build a control panel that controls lights based on a music input signal.
My Design Criteria is:
Lights should [blah, blah, blah…]
I want to control [blah, blah, blah] to make the lights [blah, blah, blah] …
My desired INPUTS are:
1- Rotary potentiometers
2- ?
3- ?
4 - ?

etc. etc. etc.

Is there a remote chance you are trying to build a “color organ” ?
COLOR ORGAN

Are you aware that if you put a graphic equalizer on the front end of a color organ you can increase or decrease sensitivity to specific frequency bands. I built an 8 band equalizer using pots and op amp active filters (band pass filters). A band pass filter is made by combining a HIGH PASS filter with a center frequency of x and a LOW PASS filter with a center frequency of (x +y), the result is that any frequency greater than x and < y will pass to the output, but an active filter has a pot for the INPUT signal amplitude and another for the GAIN, consequently you can both attenuate the input signal to THAT band AND/OR increase/decrease the gain for THAT band. When you have 8 bands (from the LOW range to the HIGH range coupled with 8 different colors of lights, you use the electromagnetic spectrum
Electro-magnetic spectrum

to choose your colors , picking red for the lowest band and violet for the highest with LITE ORANGE, DARK ORANGE ,YELLOW,LITE GREEN,DARK GREEN , LITE BLUE, DARK BLUE or any combination of these
colors. Mine used 7W teardrop shaped Christmas Tree lights Christmas Tree Light bulbs.
I tested it with the classic 1960’s Color Organ Benchmark Test track: Jimi Hendrix Voodoo Child.
I’m having flashbacks just thinking about it… :grin:

You can control 50 LEDs but not with the arduino pins directly. That would overcurrent the processor. Use a transistor to drive each LED is recommended. Programming is the same as driving an LED directly with an arduino pin. Google N-channel MOSFET, which is a type of transistor suited for this purpose.

Raschemmel, like I said to Wawa, I use the term "midi controller" loosely. My goal is very simple, I want 16 potentiometers mapped to various parameters in ableton live. I will use Max for live to map the serial data from the arduino to the controls in ableton. I will build a simple wooden box with a plexiglass top to set the pots into. Underneath the glass, I am hoping to just set up an array of leds that I have programmed simple light patterns with. I do not want the lights to be controlled by the pots, I only want them to light up the inside of my box in various ways. So:

  1. Lights are simply that, lights. There are a bunch of them, maybe doing some kind of movement or pulsing. But ultimately, they are just lighting up the box.
  2. Potentiometers are only responsible for sending out serial data.

While a color organ sounds awesome, that is not what I am going for. At most, I may have the Pots simply control the leds closest to them, but I am not overly worried about that.

Liudr, you say 50 leds but not with the pins? I do not understand, that is exactly how I power the leds; with the pins. So I have Wawa saying I can control 100's of leds with no issues, and Liudr saying that 50 would overload the processor.

Ok. I'm not familiar with Max or ableton so I'll bow out here. Good luck.

The ATMEGA2560 chip can have a total of 200mA on all pins so if you spend all that on 50 LEDs, then each one can support a maximal of 4mA. It's not very bright with only 4mA. Also the rest of the chip consumes current as well so your actual current per LED is even lower. Yes, you have lots of pins, but no they can only source up to 200mA as a whole. With a transistor you can easily supply hundreds of mA per LED so you can afford to light your device a lot brighter.

The Atmega has 4 VCC pins and thus can have 800mA spread across the ports per the notes following Table 30-1:
3. Although each I/O port can sink more than the test conditions (20mA at VCC = 5V, 10mA at VCC = 3V) under steady state
conditions (non-transient), the following must be observed:

ATmega640/1280/2560:
1.)The sum of all IOL, for ports J0-J7, A0-A7, G2 should not exceed 200 mA.
2.)The sum of all IOL, for ports C0-C7, G0-G1, D0-D7, L0-L7 should not exceed 200 mA.
3.)The sum of all IOL, for ports G3-G4, B0-B7, H0-B7 should not exceed 200 mA.
4.)The sum of all IOL, for ports E0-E7, G5 should not exceed 100 mA.
5.)The sum of all IOL, for ports F0-F7, K0-K7 should not exceed 100 mA.
If IOL exceeds the test condition, VOL may exceed the related specification. Pins are not guaranteed to sink current greater
than the listed test condition.
4. Although each I/O port can source more than the test conditions (20mA at VCC = 5V, 10mA at VCC = 3V) under steady
state conditions (non-transient), the following must be observed:

ATmega640/1280/2560:
1)The sum of all IOH, for ports J0-J7, G2, A0-A7 should not exceed 200 mA.
2)The sum of all IOH, for ports C0-C7, G0-G1, D0-D7, L0-L7 should not exceed 200 mA.
3)The sum of all IOH, for ports G3-G4, B0-B7, H0-H7 should not exceed 200 mA.
4)The sum of all IOH, for ports E0-E7, G5 should not exceed 100 mA.
5)The sum of all IOH, for ports F0-F7, K0-K7 should not exceed 100 mA.
If IOH exceeds the test condition, VOH may exceed the related specification. Pins are not guaranteed to source current
greater than the listed test condition.

Add 'em up - that's 800mA. I have posted a reply direct from Atmel in the past stating the 200mA is per each VCC & Gnd pin.

Thanks for all of the input. This quickly went over my head, but that's a good thing! For now I have more to learn. Thank you thank you.

So according to CrossRoads, maybe up to 10mA for each arduino pin to power an LED, not too dim actually.

Thanks CR. I did read 200mA per power/gnd pin but forgot the chip has 4 pairs.