60 LEDs using Arduino Mega w/ Ethernet Shield

I am wiring up an Arduino Mega with an ethernet shield that will have about 60 LEDs. The shield has the POE module installed to power the Arduino board from the ethernet cable.

The LEDs will be controlled over ethernet from a server app and they will indicate a status when activated/deactivated.

Attached is a schematic of what I plan on doing. I haven’t created anything of this magnitude before so I don’t know if this is the best approach. I have taken this approach because I wanted to minimize any extra components.

Is this a good approach or should I take a different route? Any input would be greatly appreciated!

Hello !

What is the consumption of ONE led ?

Indeed, the Arduino Output accepts 20mA/GPIO. It will obviously NOT accept to drain 60 LEDs at same time.

I propose you to add eight 74HC595 which are Shift registers. It will allow you to control the 60 LEDs with only 5 pins. (5V, GND, SCLK, LATCH, DATA).

Moreover, the current will not be drained from the Arduino but from the the 595. I am sure you do not want to burn your freshly bought Arduino :stuck_out_tongue:

Finally, you can also work in common anode mode :

Example to connect 595 in series.


source : http://www.protostack.com/blog/2010/05/introduction-to-74hc595-shift-register-controlling-16-leds/

USAGE :
The 595 is REALLY easy to use.

  1. Leds are in a certain state
  2. Pull the latch down
  3. shiftOut the bits => The 60 bits will be loaded into the shift registers.
  • shiftOut works so : Pull clock up, set data pin, pull clock down, loop for bits
  1. Pull the latch up => The 60 bits are written on the 595 output.

The code will looks like :

// Maintain a byte buffer_data variable with the current state of the Leds.
// Everytime you change the buffer, "send" the buffer to the 595 shift registers.
void send(){
  for(int i=0;i < 8; i++){
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, buffer_data[i]);
    digitalWrite(latchPin, HIGH);
  }
}

Hope it helped

JonKrzecki:
Is this a good approach or should I take a different route? Any input would be greatly appreciated!

Sixty LEDs?

As a status display?

You want a MAX7219.

Matrix modules available cheap on eBay. You may not want the 8 by 8 matrix itself, but the PCBs are very convenient to use - get one of the unassembled ones, mount the chip, resistor and two capacitors and wire it to your LEDs (as a matrix of course). Plenty bright in general.

No need for Mega - only if you need extra program space.

Thanks for your inputs!

They would be the standard white 20ma LEDs used as a backlight for a template text overlay on top of them. The server app will send the arduino which light to turn on and the text lights up and will indicate a certain status.

I will look into both of the options above. I have seen 8x8 led matrix wired directly into arduinos pins but i'm sure there is an ic involved in those. We wanted to use the least amount of components. There will be other arduino megas with switches hooked up to them that will relay their status back to the server app and we figured it would be best if we just used the same boards for all of it in case they ever want to expand on this project.

Thanks you both for your guidance!

I offer a break out board for MAX7219 that makes it easy to wire up individual LEDs:
http://www.crossroadsfencing.com/BobuinoRev17/


Someplace I have a pic of a bunch of LEDs with 2 wirewrap wires each going to posts plugged into the board. Can also just wire to the posts, or the holes directly and leave off the headers.

JonKrzecki:
We wanted to use the least amount of components.

You cannot run 60 leds without some extra components. You have only 54 digital outputs. There are 16 analog inputs, I don't know if they can also be digital outputs like they can on Uno. Even if that is the case, you will need 60 series resistors, and you will have to limit the current to a few mA each or you will overload the Arduino.

in general, Max7219 will be the solution with least components. Only one resistor, plus 2 capacitors.

However, if only a limited number of the 60 leds will be lit at any time, there may be other simple solutions.

There are 70 IO , all can be used as digital outputs.
The problem is current capability - the Mega can support 800mA thru the VCC/Gnd pins, but the current must be spread across the ports:

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 200mA.

2.)The sum of all IOL, for ports C0-C7, G0-G1, D0-D7, L0-L7 should not exceed 200mA.

3.)The sum of all IOL, for ports G3-G4, B0-B7, H0-B7 should not exceed 200mA.

4.)The sum of all IOL, for ports E0-E7, G5 should not exceed 100mA.

5.)The sum of all IOL, for ports F0-F7, K0-K7 should not exceed 100mA.

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 200mA.

2)The sum of all IOH, for ports C0-C7, G0-G1, D0-D7, L0-L7 should not exceed 200mA.

3)The sum of all IOH, for ports G3-G4, B0-B7, H0-H7 should not exceed 200mA.

4)The sum of all IOH, for ports E0-E7, G5 should not exceed 100mA.

5)The sum of all IOH, for ports F0-F7, K0-K7 should not exceed 100mA.

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.

60 LEDs means 60 current limit resistors as well (can be resistor networks to save room). MAX7219 to drive 60 makes more sense, or use shift registers and shiftPWM library, or use a driver like WS2803 with 18 IO and 8-bit PWM control per output.

Our mega and ethernet shield with POE came in and we ordered up the max 7219 along with the ceramic caps and a gangle, a group, a bag of 3.3v 20ma white leds. We’ll breadboard it all up and see if it suits our needs!

We’ll most likely need a breakout board kit since we’ll need to use phoenix connectors for the final solution.

We were also looking at using a transistor solution with a seperate power source for the leds, which i understand is not efficient in using the IO but it seems like it would get the job done.

Either way, when we get the parts we’ll play around with all these suggestions! thanks for the replies and I’ll check out the breakout board right now.

Ok, I have in stock and can ship next day, sometimes same day, with your paypal payment.
http://www.crossroadsfencing.com/BobuinoRev17/

I finally got the max7219 all wired up and working with an old Deumilanove and it it works with the "LedControl.h" library.

I was going to to upload my test sketch to my mega with ethernet shield but I noticed that it notes that pins 10,11 & 12 are reserved for the ethernet board.

Would I be able to use the ethernet board and max7219 on the same pins?

CrossRoads I've looked at your board and that is awesome! I am going to get one of them to retain sanity from jumpers and breadboarding and because it makes it so simple! But i guess the question would be the same for your board. Would I be able to use it with the ethernet shield?

I also saw you have a mega screw shield! Would that work with the ethenet shield also?

You can use any three pins to control the MAX7219. You do not need to use the "LedControl.h" library if it is restricted to certain pins, it is merely a minor convenience.

Paul__B:
You do not need to use the "LedControl.h" library if it is restricted to certain pins.

Its OK, that library can use any 3 pins.

You people are amazing. Thank you!

Many people would say "Why don't you just map different pins and try!" and feel like I would like to check with more knowledgeable people in the community rather than risk damaging the mega or ether shield or the max even though i know these things are built like tanks for entry people like myself.

Thanks to you all!

Jon

JonKrzecki:
i know these things are built like tanks for entry people like myself.

Not true, Jon. Its all too easy to damage an Arduino, we are always telling newbies that they have probably already done so.

But in your case, the max’s 3 inputs won’t do any damage no matter which arduino pins you connect them to. That’s because they are just that - inputs. You can connect inputs to outputs, which is the right thing to do, or inputs to other inputs, which won’t work but won’t do any damage either. Its connecting outputs to outputs which can damage, or connecting outputs to anything without regard to the amount of current that will flow, for example leds without series resistors.

Finally finished making a matrix and tested out all leds and it works thanks to all of you!

one last question that i can't find from searching around: if i wire up 2 leds to each matrix point (total of 128 leds, 2 leds in parallel on each point ), do i need to offset the resistor on the max or is this not possible because the max is not capable of driving that many leds load?

so activating matrix point 0,0 would light up 2 leds wired up in parallel on that point. I could test it but i just don't want to overload the max chip.

You should not connect leds in parallel with max7219. This is because no two leds are identical and will not share the current equally, resulting in uneven brightness and shortening the life of the led that takes more current.

You may be able to put two leds in series: red leds have forward voltages as low as 1.8V, so a pair would have a total forward voltage of 3.6V. However white leds have Vf of around 3.2~3.5 so two in series would exceed the 5V supply of the max chip and they would probably not light at all.

In fact, if the current is set for one LED, then two LEDs of the same type in parallel will not cause any harm - but may not light evenly and one would have to ask - why would you do this?

You are most unlikely to get better brightness this way; the only reason for doing it would be to have two matrices in different places indication the same. It may work well enough.

I will test it out in series since it won't kill the max. The brightness is a non issue since even with the intensity set to 1 on the chip, it is plenty bright enough. So if this works, it'll be a win win for us.

The reason why we want to pair up 2 leds to one point is because this whole system will be in a status panel. the light modules that we have (and would like to reuse) are square indicators. these indicators will display the flow of...air lets say. the indicators have 2 indications, horizontal and vertical.

the horizontal is green and the vertical is red. Both have 2 lights per indication. Here's a simple image of its layout: (each segment is seperated from light bleed from the other leds{this is an extremely crude layout image})

Our thoughts were that if we wire up 2 leds to a single point, we can control a single axis(green or red) with a single line of code rather than 2.

Why don't we just add another line of code and another chip? or why don't we modify the the indicator housing to use a single led? we have about 187 of these little buggers our enthusiasm is proportionate to the work load and the easiest path.

In other words, we just want to do this in the easiest way possible so if anything needs to be replaced, it can be with the original spares.

i will read up on how to wire leds in series!

This is what you should have told us in post #1!

Are you free to wire the leds in series or parallel?

What is the forward voltage of the red leds and the green leds?

How far apart will these indicators be located?

If you use LEDs from a single batch, you will likely find that they will work in parallel.

You could in any case equalise the current by putting a small resistor (22 Ohms perhaps) in series with each.

From a wiring convenience point of view, you could use two matrix points to connect the two LEDs and have a second MAX7219 to double up on the number.

Surely you did not buy only one MAX7219?

And if you needed to duplicate the display in a separate location, you could of course use a second MAX7219 connected to the same three control pins as it is completely passive and the code does not depend on any handshaking from it. If you want two MAX7219s to show the same data, you connect them in parallel, if you want them to show different data, you chain them.