Driving 36 leds with different colors using max7219


I’m new to this forum so I’ll introduce myself quickly! I’m a software developer living in France and I really like DIY. I have some experience with arduino and espruino (javascript controlled μc) so I know how to program it, but I’m not so good on pure hardware design (like transistor usage for example).

I’m trying to do a rev-counter for my motorcycle using 32 leds + 4 (for neutral, turn signal…)

The rev-counter will go up to 8000 rev/min, so I’ll use an orange led every 1000 rev/min. A green led will be used every 250 rev/min, and I’ll use red leds between 7000 and 8000 rev/min.

It will look like this:

v v v o (1000 rev/min) v v v o (2000) … v v v o (7000) r r r o (8000)

I wanted to use a max7219/7221 to drive the 36 leds. I saw I could maybe use a shift register, but I’m a bit scared to do the multiplexing myself. I’ll use an attiny 85 to drive the max7219.

The biggest problem is that the leds are not the same color and I want them to be of equal brightness. I bought this pack on ebay (in french sorry).

  • Red diffused led : 800 to 1000mcd at 20mA - 1.9 à 2.1V
  • Orange diffused led : 600 to 800mcd at 20mA - 2 à 2.4V
  • Green diffused led : 150 to 200mcd at 20mA - 1.9 à 2.1V

They are good except the green one which are not so bright even at 15mA (I can’t see if they are shining under direct sunlight). The orange and red leds are bright at 15mA.
I found some bright leds on farnell so I’ll order them and I think that it should solve the brightness problem.

But I’m a bit scared because they’ll maybe be too bright compared to the orange and red leds. I know I can set the delivered intensity of the max7219 using Rset value, but it will be applied on every leds.

Do you think it is possible to add resistors between max7219 and the leds to adjust the brightness ?
An other option could be to do PWM with a small duty for the green leds and an higher one for the orange for example, but I don’t know if I can do PWM if I use a max7219 (I think it should be OK since the scan rate is about 800Mhz if I’m not mistaken).

Do you think the max7219 is good for this usage (driving leds with different colors), or do you know other solutions to solve this problem ?

Thank you very much for reading this and have a good evening :slight_smile:

Look into LED strip. WS2812B.


Thanks for your reply !
It looks promising, but the leds won't be arranged as a straight array. Here is a picture of the counter :

I saw adafruit sells individual 5050 leds, but they are flat. If possible, I would prefer rounded shape that fits in the holes I drilled :slight_smile:

Adafruit says that the 5050 leds are driven by a WS2811 chip that are great to drive a rgb leds (or 3 single color leds) at a constant 18mA output current. I could use that to drive my leds, but I guess the problem remains since my orange leds won't match the brightness of my green leds at this constant current. The max7219 is also a constant current chip, that's why I'm wondering if you can add a resistor between the chip and the led to decrease the current without frying the chip. Is it possible to decrease the current provided by a constant current IC ? ahhh it drives me mad :grin:

Is it possible to decrease the current provided by a constant current IC ? ahhh it drives me mad :grin:

If you place a resistor in series, the constant current output of the max chip will increase the voltage to achieve the save current as before. Of course, it cannot increase the voltage beyond the 5V supply voltage, at that point the led will start to dim, so it may be possible by doing that.

I think multiplexing may be a mistake for your project. To be viewed in full sunlight, you need maximum brightness and current. When you use multiplexing, either by having the Arduino perform the multifunction, or by using a multplexing chip such as max7219, you will immediately loose a lot of brightness.

AdaFruit sell 5mm neopixel LEDs. They are quite expensive.

You could consider these apa106 leds. They are similar to ws2812b in that they are rgb with a driver chip in each led.
s-l300 (11).jpg

s-l300 (11).jpg

Wow that seems to be great, thanks a lot !

It should be simple to wire them up together, and it saves me some space since I won't need an IC to drive them :slight_smile:

It's maybe a bit overkill for my usage since I won't change the color of the leds but it's not so expensive so I'll maybe go that way.

Do you think that the brightness of the different colors is similar ? From the video I saw on youtube, it seems to be great. I'm also trying to find a datasheet that gives the brightness in mcd to find if it is bright enough under direct sunlight (again, it looks OK on video).

EDIT : found a datasheet => http://cdn2.boxtec.ch/pub/diverse/P9823.pdf

I didn't saw your edit. That's really interesting
I'll go the apa106 way, it seems to be a good solution. I don't want to use the max7219 at the edge with resitors as it's not meant to be used like this.

Thank you ! I'll keep you in touch with the updates :slight_smile:

The brightness of the colours should be about equal, because the LEDs are designed to produce something close to white light when all 3 colours are on together. If they were not equal, the white would be a pastel colour.

Of course, yellow will look brighter than green, because yellow is made by lighting the red and green LEDs together. But you can dim the red and green LEDs to give a similar brightness to the green.

If you are lucky, the pins on the LEDs will be long enough to bend over and reach to the next led in your counter to be soldered. You may need to put some shrink sleeving onto the 5V & data lines to prevent short circuits.

Another thing you will want to do with your circuit is have an ldr measure the ambient light level and dim the LEDs. If they are bright enough to see in sunlight, they will be much too bright and distracting at night.

Thank you for your advice !

I ordered the LEDs on amazon since they were a bit cheaper : https://www.amazon.fr/abaotech-50pcs-Bead-Built-APA106/dp/B079224L37/ref=sr_1_1?ie=UTF8&qid=1522909422&sr=8-1&keywords=apa106

I don't know if I'll measure the ambient light level. I'll maybe just add a push button to change the brightness. But I'll look into this if it's simple enough.

I'll keep you informed of the progress of the project :slight_smile:

I don't know if I'll measure the ambient light level. I'll maybe just add a push button to change the brightness. But I'll look into this if it's simple enough.

Its simple. You just need an ordinary ldr and a fixed resistor, e.g. 10K. Use them to form a voltage divider and feed the output into an analog pin. Of course, you have to site the ldr somewhere that it can sense the ambient light level.