2

I would like to manage many LEDs from my Arduino - 12 or so - but I do not have the available digital pins to do this. Only one LED needs to be on at one time. Instead, I was hoping to control these with an analog pin. I was wondering if there is some sort of switch out there which can take an analog signal and, based on the value, direct a 5V current to a certain LED.

I realize that I could use a second Arduino for this, but I am trying to avoid that.

Thanks in advance for any help!

  • 2
    Please check out this question: arduino.stackexchange.com/questions/117/… it contains many answers enumerating several different solutions to the problem. – jfpoilpret Jun 18 '14 at 5:08
  • 1
    It should be noted that analog input pins still only output digital signals; only the PWM capable pins can emulate analog signals and they are dispersed among the digital pins. – BrettAM Jun 19 '14 at 23:43
1

You can accomplish this digitally with a device called a decoder. For example, the 74154 takes 4 inputs and maps those to one of 16 outputs (depending on the binary coding of the inputs). From the data sheet:

The 74HC154; 74HCT154 decoders accept four active HIGH binary address inputs and provide 16 mutually-exclusive active LOW outputs.

3

If you have 4 pins available, you could use charlieplexing to selectively light up 12 led. charlieplexing

Alternatively you could use some IC. You could use the one Greg suggested.

Or you could use a shift-register. This requires only 2 or 3 pins, an will enable you to light up any one or more leds at the same time. Most have 8 outputs, but you can connect one to the other (daisychain), so with 2 shift-registers you can individually turn on/off 16 leds. You can easily control these using arduino's shiftOut command.

You could also use a port-expander using I2C to talk to it. More complicated, and a bit more expansive. But also more powerful. It will require only 2 pins (A4, and A5).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.