I'm programming an arduino uno using C. I'm using an RGB led on three PWM outputs. However, now comes the need to connect more LEDs, a hundred LEDs at the same time, but in addition to not having the necessary ports I need a solution to be able to control the LEDs individually.
Partial Solution :
This question is actually two: how to connect and how to program. (Of course, it is important to know how many ports you have…)
I'm just going to talk about the connection.
The LEDs only light up if the current passes in the right direction. Therefore, it is possible to place 2 LEDs between each pair of doors (with opposite directions).
If between each pair of doors
(n*(n-1))/2 put 2 leds you get a " Charlieplexer "
If you have 11 ports (and enough wire…), you can directly use the Arduino in "CarliePlexing" controlling 11*10 leds.
(Arduino ports may be in "+" "-" "off" state).
Unfortunately we cannot have both LEDs (p1=+,p2=-) and (p2=-,p1=+) turned on at the same time. However, if with the controller we switch between the two with speed, we will see both connected.
If you have "few" ports you may need additional hardware (multiplexers or similar)
Update: Using external hardware (–> find arduino+multiplexer on uncle google…)
Multiplexers allow you to "demultiply" outputs/inputs. For example a 16 multiplexer/demultiplexer will need 4 pins to select the desired output and one more for the signal.
Multiplexers can be chained…
For example at: https://miullinglam.wordpress.com/2010/04/19/arduino-multiplexing-example-1/ you will find an arduino with 3 8-channel multiplexer chaining.