# LED Matrix with Game Controller - A First Project

This project was built for my introductory electronics class at the University of Waterloo in Canada.  This was my first introduction to electronics and therefore, my first project.

Follow these steps to build a 16 x 16 LED array with a wall (different colored LED on the border), powered by an Arduino Mega 2560.  I have also included the construction details of a game controller.

This project is ideal for a beginner, as it introduces you to several fundamental elements in practical electronics.  You can learn how to read data sheets, how to solder, how to work with LEDs, multiplex to save output lines, program a microcontroller through an Arduino, how to take practical factors into account in design, resistances and analog considerations in digital circuits, etc..

At the end of the project, you should be well equipped to move on to more complex ones such as LED cubes or rotating displays.

Remove these ads by Signing Up

## Step 1: Multiplexing Basics

In order to have an LED Matrix of any significant size, you'll need to control more LEDs than you have outputs.  You can multiplex your LEDs to accomplish this.  It works like this:

The LEDs are arranged in a rectangle.  The anodes are soldered together in one direction and the cathodes are soldered together perpendicular to the anodes.  When all cathodes are high and anodes are low a negative voltage is applied to every LED, and if the voltage is low enough (see 'choosing LEDs' in components section), it will not breakdown.  To turn on a particular LED, turn its cathode line low and anode line high.  For example, to turn on LED (4,2) in the diagram, you would set segB to high and Dig4 to low.

The setup uses POV (Persistence of Vision) to draw an image on the array.  Each LED required to draw the image is turned on one at a time, and looped very fast, giving the illusion that all LEDs are on at the same time (see programming section).

In this project, I used the Arduino Mega 2560, and assigned 16 outputs to cathodes and 16 to anodes.  I used the HIGH voltage output (5V) as the power source.  This was done for simplicity in a first project.  However, if you can, you should avoid using a digital signal as a power source.  There are a few reasons for this.  Digital outputs are signals, and aren't designed to provide much current.  You can breach the per-line or overall current limit of your microcontroller (40mA per line supply/sink for the Atmega) if your circuit draws much power.  Also, the digital outputs in the Arduino and virtually every board are directly wired to the microcontroller without a fuse.  This makes the microcontroller vulnerable to errors in your wiring.  A simple short circuit, for example, can potentially render the pins or the microcontroller useless.  However, the main fuse that limits overall current draw should prevent this.

The Ideal solution is to use the digital outputs to turn on/off a transistor at each line, and use an external power supply to drive the circuit.  This increases wiring complexity, and of course, you need an external power supply for this.  If you are building this as practice before you build more complex projects like a cube, you should consider going the transistor route.  If you are doing this as a small project, your LED array won't be too large, or you're constrained on time / cost, then you can skip using transistors.

If you are using an external power supply, you can also consider using shift registers and the function shift_out to increase the number of your output pins.  This increases wiring and programming complexity, although it is almost impossible to construct projects that needs the controlling of large numbers of LEDs, like a cube, without it.
klīvmanis9 months ago

Nice project!

I have a question. Could i use arduino uno r3 for this project?

#Begginer

7 months ago

it has less number of input ports than mega ,so u can create 7*7 not 16*16 ..not sure though

Dylan4011691 year ago
How does it know what pins to write out to?
beat_swamp2 years ago