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!

Rip Leeb
  • 367
  • 1
  • 10

3 Answers3

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).

Gerben
  • 11,332
  • 3
  • 22
  • 34
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.

Greg Hewgill
  • 224
  • 1
  • 6
0

You can use some of the analog pins to clock a shift register by defining them as a digital output. Also two of the analog pins are also defined as I2C depending on your code. You could use 2 PCF8574s or an PCF8575 expansion board and control it that way. They can be used as inputs and outputs any order you want. There are a lot of other chips you can use to do this. The reason I am suggesting this approach is later you will probably want to expand into other peripherals such as LCDs etc.

Gil
  • 1,863
  • 9
  • 17