Steer multiple LEDs with one microcontroller pin


I want to show a program state with LEDs. There are 22 steps, each step is represented by an LED.

  • only one LED is on at a time
  • the sequence is set (forward or backwards).

I have only one pin left on my MCU, maybe two.

Basically, I'd like to have the pin work as a 'clock'. For every pulse, the "next" LED is switched on, all other LEDs are off.

I could use a clock to binary IC. (e.g. 74HC393 Binary Counter) This would create a nibble, which I could then feed into a multiplexer (e.g. 700-MAX336CPI+) which would switch one of its 16 outputs on at a time. (I can live with 16 steps).

I want to make it relatively cheap. I wonder if there is a more elegant solution. Maybe with a specialized IC, or if there is a solution with simple discrete components, oh, maybe I could even use a little servo to point at the right step… What comes to your mind?

Best Answer

I'd use 3 4017 counters, chained together. Just clock the chain from your microcontroller. The 4017 is very cheap, has an output for each LED (so no decoding), and can be set up very easily to be chained. You would need 3 for your application. The 23 pin output should just reset them all to restart the count.

Edit: You might be able to hack up something using diodes and pull-downs to test whether the 'reset' (ie, the 23 output) is high using the clock pin. A diode from 23 to the clock output through a 10k resistor, with a 100k resistor at the pin as a pull-down. When the clock is being driven low by the uC, momentarily change it to an input. If it stays low, it's not the end yet. You might also have to test 24 (ie, have them both connected to clock through a diode and 10k resistor) since the pullup will probably clock it again (but only once, until you drive it low again). Not sure, haven't tried it, but probably.

Much easier just to blow another uC pin to test 23, but you said you didn't want to do that.