Created 31 March 2009, edited 1 Nov 2020
Once you’ve mastered microcontroller programming, you might be tempted to control a lot of LEDs. Lots of people have this desire once they master the basics. Many microcontrollers have a limited number of output pins, however, so you might think that limits how many LEDs you can control. I’ve written about a few different methods around this before in chapter 14 of Physical Computing and in this blog.
By matrixing your LEDs, you can control many more than the number of pins you have. For example, with the Arduino Uno and earlier models, you had up to 20 digital outputs (13 labeled digital I/O 0 through 13, plus the six analog outputs, which double as digital I/O 14 through 19). With 16 of those, you can control an 8×8 matrix of LEDs. That’s 64 LEDs. With the Arduino Mega, you have 54 digital I/O pins, so you can control a lot more. This example uses 32 of them to control 2 8×8 matrices, for a total of 128 LEDs from one controller.
To make this example, you’ll need:
- Arduino Mega
- Breadboard or prototyping shield.
- 8×8 LED matrix. I got mine in a surplus shop in China, but you can also get them from most electronics retailers
- male pin headers
- female pin headers
- Wires