Electronics > Beginners
Want to control 12 LEDs but there is not enough pins on Arduino?
(1/5) > >>
engineheat:
Hi,

I have an application where I need 12 LEDs to light up at different situations. But each LEDs requires a signal pin and the Arduino Nano (can't use bigger Arduino due to other reasons) don't have enough pins since I also need to control some servos and stepper motor.

I would hate to use a 2nd Arduino because the LED response is related to the actions of other parts of the program. Theoretically I only need 4 bits to uniquely identify each LED, so I shouldn't need 12 pins. But how do I implement something like this?

Thanks
mathsquid:
You could try charlieplexing, or use a couple of 74hc595 shift registers.
Kjelt:
As they say above or what we used back in the good ol days a HEF4515B 4 bits to 16 outputs decoder.
Nusa:
led direct = 12 pins for 12 led's
led multiplexing = 7 pins for 12 led's
led charlieplexing = 4 pins for 12 led's
led shift register = 3 pins for any reasonable number of led's, since shift-registers can be chained.

Searches on any of those terms will give you the details very quickly.
mariush:
There's LED drivers ... some work just like shift registers.

Here's a 16 channel one for 1$ : https://www.digikey.com/product-detail/en/stmicroelectronics/STP16CPC26TTR/497-11985-1-ND/2772290

There's also versions with the pins more spread out, for example this one has 1.27mm spacing for the pins : https://www.digikey.com/product-detail/en/stmicroelectronics/STP08DP05MTR/497-6118-1-ND/1654043
You could bend each odd pin down so it goes directly in a 0.1" spaced circuit board and every even pin could be soldered to the next row of holes

Also multiplexing, for example have 3 groups of 4 leds ... power each group from a 5v pin so you have 3 pins reserved to send power to the leds (pins on output). Set the 4 pins as input to have current flow into the micro ... add resistors to limit current.  Power the leds you want from first group, wait a bit of time, turn off leds and power to first group, turn power to 2nd group and set the right leds, repeat..
This way you control 12 leds with 3+4 pins.

For a lot of current you could use something like ULN2003
Navigation
Message Index
Next page
There was an error while thanking
Thanking...

Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod