microcontrollergpioledrenesas-rx

Multiple LED control with few GPIO pins in Renesas microcontroller


I need to control 12 leds through 4 GPIO pins. I did some reading online and saw we can use Charlieplexing method to control leds with fewer gpio pins. But is it possible to make two or more leds to glow at the same time in this method. Those 12 leds are grouped into 4 groups(3 leds in a group) and 1 led would be lit in each group at a time.

Anybody used this method or any other method please provide some guidance on how to go about this implementation. I'll try it. Thanks.


Solution

  • You can turn on more than one led, using 4 GPIOs (let's alone the current limiting problems - hardware problem), but not in any combination.

    BUT: if you manage to turn on any single led at a time, you can fool the user by turning on multiple leds, one after the other, in a quick loop. At any given moment only a LED is on, but the human eye continues to see it lit for about 1/20th of second.

    Have a interrupt run every ms (or so), and a mask of 12 bit indicating which leds have to be on. The interrupt handler continuosly "rotates" the GPIOs in order to touch every combination of rows and columns, and in the same time rotates a bit in an internal register (1000b, 0100b, 0010b 0001b, then reload 1000). When the AND of the internal register and the LEDs mask is not zero, the GPIO configuration must be left active, otherwise set the GPIO to off.

    Update: forgot to mention, keeping the LEDS on for so short time, will make them less bright than normal. You can partly correct this by allowing more current (up to a safe limit), and/or by choosing brighter LEDs...