Arduino Mega 2560 capabilities??? (Two Parts)

Hello and a good day to you all...

First of all great great community and plenty helpful...

Secondly, I went through quite a lot of posts on here and couldn't actually find out the answer I was looking for... I want to know how many LEDs simultaneously can I run off of and arduino mega 2560, keeping only 1 LED on one pin??? I have to run at least 20 (40 in total) individual LEDs and each one is turned off or on individually, but at least 20 LEDs are on at any given moment... If Mega can't handle it any other easy to use solutions??? Preferably Not involving Transistors Please...

Second part of the question is, I am building kind of a Dash Board and it has buttons on it which show the status of the related item like Locked or Unlocked and pressing the button toggles the state of the connected item. Different color of LEDs are there to show the status like RED for Locked and Green for Unlocked, I was wondering was there a way to use only one arduino pin to toggle between two LEDs... Like when the red is off green goes on and when the green is off the red goes on but only one pin of arduino is used. What I want to do is Use 20 Switches (Push buttons type) and they are going to take 20 pins, I only want to sacrifice 20 more for the status LEDs...

Many thanks in advance to all of you for the help guys...

Hi,
Mega has 54 I/O's so you should be fine.

If a large percentage of LEDs will be on at once, consider using good high-brightness LEDs and use series resistors of 470 ohms or so, to limit the current.

Ideally you would calculate the resistor values based on the LED Forward Voltage rating, which varies with COLOR..

The switches can just go from an I/O pin to ground, using "Input Pullup".

You can control any combination of LEDs in your code, based on what information you have..

HERE is a nice LED Tutorial...

Thanks for your time mike...

terryking228:
Mega has 54 I/O's so you should be fine.

HERE is a nice LED Tutorial...

Yes it has 54 pins, but 13 of them are doing something else and I only have 40 pins left to work with...

terryking228:
If a large percentage of LEDs will be on at once, consider using good high-brightness LEDs and use series resistors of 470 ohms or so, to limit the current.

Ideally you would calculate the resistor values based on the LED Forward Voltage rating, which varies with COLOR..

HERE is a nice LED Tutorial...

I will be using bright LEDs and the resistors that I will be using are 330 Ohms because they give me the best brightness and don't heat the LEDs up...

terryking228:
The switches can just go from an I/O pin to ground, using "Input Pullup".

HERE is a nice LED Tutorial...

I have the TP223 Touch switches and they have their own separate power source and only require a signal pin to be connected to arduino's input pin to function, so Wiring them up is pretty simple... They are not the issue, I need to know How many LEDs can I safely drive off of the Mega without worrying about damaging the board...

And need a way to have two LEDs toggled through only one Arduino pin... Like when I push the button it goes red, if the push the button again it goes green, again red and again green and so on... 20 buttons, 40 LEDs and 20 LEDs on at any given moment...

Hi,

You need to check against the total pin current limitations. See:

http://arduino-info.wikispaces.com/ArduinoPinCurrent

You can use a single I/O pin to turn on one of two connected LEDs.

~~They COULD have a common resistor, one LED to Vcc, one LED To ground. ~~ As Paul pointed out, this doesn't work! With 5V Vcc the voltage drop across a reasonable resistor is enough to light an LED. They get brighter and dimmer, but not enough!

~~But if the color differences are enough (Red and Green are quite different) you may want separate resistors.~~

You will want separate resistors: A resistor-LED from pin to Vcc and another resistor-LED from the same pin to ground.

At Arduino reset/power up, the pins are in high impedance, and BOTH LEDs will light up.

This is a FEATURE called "Lamp Test" :confused:

Thanks, Paul!