Control 60 individually white leds (no led strip)

Hello:

I have installed 60 white leds individually and I need to light on every led individually. i mean, for example: ligth on the led 21 and the others 59 light off. Then when I want, light on the 43 led and the others 59 light off.

I know that is easier to use leds strip but I just have installed on a plaster model the 60 leds in its proper position. And the wires are out. So, what do I need (software and hardware) to do this.

thank you very much

One solution could be to use several shift registers, e.g the 74HC595. One shift register controls 8 leds, and they can easily be daisy-chained. With a chain of 8 74HC595's you can control 64 leds, through three pins on one Arduino Uno.

If you have access to both wires of all LED's I would simply the hardware by multiplexing it. With an 8x8 matrix you can control every led. If they are normal LEDs you only need column drivers or, if that's alright, (really) stay under 5mA per LED (aka 40 per pin) (or never turn on all LEDs in a column).

You can even place 2 leds anti-parallel (if you stay under 40mA per pin) and get away with a 5x6 matrix.

This MODULE LED DISPLAY 8X8 MAX7219 is ok?

how can I connect every led to this module?

many thanks

amjlopez:
I have installed 60 white leds individually and I need to light on every led individually. i mean, for example: ligth on the led 21 and the others 59 light off. Then when I want, light on the 43 led and the others 59 light off.

How many lights do you want to (appear to) be lit at once?

If the answer is only 1, then you can do this with 9 Arduino pins and 8 series resistors. No chips required.

amjlopez:
This MODULE LED DISPLAY 8X8 MAX7219 is ok?

how can I connect every led to this module?

many thanks

Check the datasheet for the MAX7219, it is all explained in there. In detail.

PaulRB:
How many lights do you want to (appear to) be lit at once?

If the answer is only 1, then you can do this with 9 Arduino pins and 8 series resistors. No chips required.

Good old Charlieplexing? :wink:

Shuzz:
Good old Charlieplexing? :wink:

You got it!

"If the answer is only 1, then you can do this with 9 Arduino pins and 8 series resistors. No chips required."

Please, can you tell me (some schema) of how to do this? 9 pins an 8 series resistors?
many thanks

Here is an example showing 64 LEDs.

Thank you:

how can I access to each led?

Have you a program demo?

where are the resitors in the schema .jpg?

And with 5 volts from Arduino is enough to light on each individual led? (I need only one led at a time)

many thanks

You access a led by setting the pin connected to the column to HIGH and the pin connected to the row to LOW and all 7 other pins set to INPUT.

The resistors can be on the columns or rows, it does not matter.

I will write a short demo program for you. It will only be a few lines long.

Yes 5V will be enough. White leds usually have a forward voltage of 3.2~3.5V and max current of 20mA. Is that true for the LEDs you have used?

Yes, it's true.
thank you very much for your support

One note, though:
It may be possible that you notice a faint glow in the LEDs that are supposed to be off.
The reason is that pins that have been switched to Input (=High Impedance) mode will still allow a certain amount of current to flow, usually substantially less than a milliamp. Depending on the LEDs used, this can be enough to make the LEDs glow.
(The resistance of pins in input mode is between 20K and 50K if I remember correctly...)

I've had that happen to me once in a project where I used very bright 10mm LEDs. Some of these LEDs would light up (albeit very dim) when they shouldn't and I quadruple checked that it wasn't an error in the code.

Nevertheless, you cannot connect a large number of LEDs with less hardware than this, period.

@PaulRB: You forgot the series resistors in your circuit diagram.

Shuzz:
(The resistance of pins in input mode is between 20K and 50K if I remember correctly...)

According to this page,

Arduino (Atmega) pins default to inputs, so they don't need to be explicitly declared as inputs with pinMode() when you're using them as inputs. Pins configured this way are said to be in a high-impedance state. Input pins make extremely small demands on the circuit that they are sampling, equivalent to a series resistor of 100 megohm in front of the pin.

With 5V supplied by the pin set to HIGH, a pin set to INPUT would sink 5/(100M)=0.05uA. I doubt that would be enough to cause the glow you saw.

Its it possible your pins were set to INPUT_PULLUP? The internal pull-up resistors are equivalent to ~50K and would source around 5/(50K)=0.1mA, which sounds much more like what you are describing.

Example code:

const byte numLedPins = 9;
const byte numLeds = 60;
const byte ledPins[numLedPins] = {2, 3, 4, 5, 6, 7, 8, 9, 10}; 

void setup() {
  Serial.begin(115200);
}

void loop() {
  for (byte i = 0; i < numLeds; i++) {
    byte anode = i / (numLedPins - 1);
    byte cathode = i % (numLedPins - 1);
    if (cathode >= anode) cathode++;
    Serial.print("led: ");
    Serial.print(i);
    Serial.print(" anode pin: ");
    Serial.print(ledPins[anode]);
    Serial.print(" cathode pin: ");
    Serial.println(ledPins[cathode]);
    pinMode(ledPins[anode], OUTPUT);
    digitalWrite(ledPins[anode], HIGH);
    pinMode(ledPins[cathode], OUTPUT);
    delay(500);
    digitalWrite(ledPins[anode], LOW);
    pinMode(ledPins[anode], INPUT);
    pinMode(ledPins[cathode], INPUT);
  }
}

Example code output:

led: 0 anode pin: 2 cathode pin: 3
led: 1 anode pin: 2 cathode pin: 4
led: 2 anode pin: 2 cathode pin: 5
led: 3 anode pin: 2 cathode pin: 6
led: 4 anode pin: 2 cathode pin: 7
led: 5 anode pin: 2 cathode pin: 8
led: 6 anode pin: 2 cathode pin: 9
led: 7 anode pin: 2 cathode pin: 10
led: 8 anode pin: 3 cathode pin: 2
led: 9 anode pin: 3 cathode pin: 4
led: 10 anode pin: 3 cathode pin: 5
led: 11 anode pin: 3 cathode pin: 6
led: 12 anode pin: 3 cathode pin: 7
led: 13 anode pin: 3 cathode pin: 8
led: 14 anode pin: 3 cathode pin: 9
led: 15 anode pin: 3 cathode pin: 10
led: 16 anode pin: 4 cathode pin: 2
led: 17 anode pin: 4 cathode pin: 3
led: 18 anode pin: 4 cathode pin: 5
led: 19 anode pin: 4 cathode pin: 6
led: 20 anode pin: 4 cathode pin: 7
led: 21 anode pin: 4 cathode pin: 8
led: 22 anode pin: 4 cathode pin: 9
led: 23 anode pin: 4 cathode pin: 10
led: 24 anode pin: 5 cathode pin: 2
led: 25 anode pin: 5 cathode pin: 3
led: 26 anode pin: 5 cathode pin: 4
led: 27 anode pin: 5 cathode pin: 6
led: 28 anode pin: 5 cathode pin: 7
led: 29 anode pin: 5 cathode pin: 8
led: 30 anode pin: 5 cathode pin: 9
led: 31 anode pin: 5 cathode pin: 10
led: 32 anode pin: 6 cathode pin: 2
led: 33 anode pin: 6 cathode pin: 3
led: 34 anode pin: 6 cathode pin: 4
led: 35 anode pin: 6 cathode pin: 5
led: 36 anode pin: 6 cathode pin: 7
led: 37 anode pin: 6 cathode pin: 8
led: 38 anode pin: 6 cathode pin: 9
led: 39 anode pin: 6 cathode pin: 10
led: 40 anode pin: 7 cathode pin: 2
led: 41 anode pin: 7 cathode pin: 3
led: 42 anode pin: 7 cathode pin: 4
led: 43 anode pin: 7 cathode pin: 5
led: 44 anode pin: 7 cathode pin: 6
led: 45 anode pin: 7 cathode pin: 8
led: 46 anode pin: 7 cathode pin: 9
led: 47 anode pin: 7 cathode pin: 10
led: 48 anode pin: 8 cathode pin: 2
led: 49 anode pin: 8 cathode pin: 3
led: 50 anode pin: 8 cathode pin: 4
led: 51 anode pin: 8 cathode pin: 5
led: 52 anode pin: 8 cathode pin: 6
led: 53 anode pin: 8 cathode pin: 7
led: 54 anode pin: 8 cathode pin: 9
led: 55 anode pin: 8 cathode pin: 10
led: 56 anode pin: 9 cathode pin: 2
led: 57 anode pin: 9 cathode pin: 3
led: 58 anode pin: 9 cathode pin: 4
led: 59 anode pin: 9 cathode pin: 5

Schematic:

I've shown 100R resistors above, but if you need more brightness, you could go down to 47R. (Don't forget that the current passes through 2 of these resistors, one on the anode side and one on the cathode side, so you can use series resistors half the value you would normally use).

PaulRB:
Its it possible your pins were set to INPUT_PULLUP? The internal pull-up resistors are equivalent to ~50K and would source around 5/(50K)=0.1mA, which sounds much more like what you are describing.

I was unable to find an explanation for the behaviour when it happened.
The code would set all pins involved to INPUT, disable all pullups and then set the pins required to OUTPUT and LOW or HIGH, respectively.
Ultimately, I switched the original LEDs to WS2812 because the project suddenly required somewhat more fancy effects... :wink:

In any case: you're correct, I re-checked the datasheet and the impedance should be high enough to prevent any residual glow. Maybe I had a faulty chip? I don't know.

It's possible that if you had an output set to OUTPUT & HIGH and then set it to INPUT, that the internal pull-up gets/remains enabled.