Electronic – How to use one microcontroller to increment/decrement 4 sets of LEDs using 8 push button inputs

ledmicrocontrollermultiplexer

I want to design a very small project for a portable score keeper. It consists of using one microcontroller to control 4 sets/groups of LEDs on a small PCB. It is a very small scale project (3.5in X 1.5in). 2 of the 4 sets will consist of 4 LEDs each and the other 2 will consist of 7 LEDs each. Total of 22 LEDs but I will only need 4 LEDs to be on at one time. I would like to use push buttons to increment & decrement the score which will light up an LED. The LEDs will be labeled by score points. The smaller set will be the game score while the larger set will be the set score.

I was wondering if this was possible and how would I do this? is there a small enough microcontroller to be able to have have 8 push button inputs to manipulate 4 separate sets/groups of multiple LEDS?

I am planning to use plain 3V coin cell batteries for now but will look into small rechargeable power supplies. I have made a very simple dip-switch prototype using very tiny surface mount LEDs on a thin PCB with a coin cell battery. The dip-switch was bulky and took a lot of space. I would to slim it down and make it more sleek with less switches by implementing these ideas if they are possible.

Any words of advice and help will be appreciated. Thank you so much 😀

Best Answer

Oli gave a good answer, but wait, mine will be better! :-)

Oli commented on the limited current from the coin cell, and that's indeed something to keep an eye on. This CR2430 cell gives 5 mA as maximum continuous. Let's see if we can manage that.

It's a good thing that you only need one LED on at a time, otherwise I would even consider the coin cell. This looks like a nice LED: typically 15 mcd at 2 mA.

Oli went for a SIPO (Serial-In, Parallel-Out) shift register for the LEDs and a PISO (Parallel-In, Serial Out) for the buttons. That saves you a lot of I/O but costs extra components. Can't we use the I/O of a microcontroller directly? 22 LEDs and 8 buttons is 30 I/Os, no problem, but we can do it a bit cheaper if we multiplex the LEDs in a 4 x 5 matrix. Normally this would decrease the LEDs luminosity by 75 %, but since we only have to light one LED at a time we can select one row and one column statically. So we need 4 + 5 + 8 = 17 I/Os.

Usual suspects for a microcontroller are Atmel AVR and Microchop PIC. Usually I'd avoid PIC for LED driving because it can't source or sink 20 mA, but we have a low LED current so no problem. PIC is also cheaper than AVR. The PIC16F57 has 20 I/Os, so that's enough. The datasheet says 22.5 µA maximum for a 32.768 kHz clock at 2 V, so at 3 V that still will be below 50 µA.

That's it. A microcontroller, a cheap crystal, 22 LEDs, 8 buttons, and 12 resistors (4 for the LEDs and 8 for the buttons. The PIC16F57 doesn't seem to have internal pull-ups). No shift registers needed.