LED matrixes are some of the most popular projects that are built using Arduinos. Its' really fun to work with LEDs and the kind of output you get from them is mesmerizing. You can use these matrices for various applications to create sign boards with scrolling texts and play animations. It's really cheap and simple to build one and it can be easily reprogrammed using an Arduino. You can even customize it to be used with the output of a music system, so we get cool synchronized visuals along with it.
In this tutorial, I will show you how to build a fancy 8 by 10 Arduino LED matrix (with scrolling text and animations) using an Arduino and a 4017 decade counter. You can also buy an assembled LED matrix online. This type of matrix is easy to make and program and it is a good way to learn about multiplexing.
How Does the LED Matrix Work?This whole Arduino LED matrix project works on the principle of multiplexing. Here, the Arduino is connected to the 4017 decade counter IC and sends the data through two lines. The multiplexed data from the Arduino is then decoded into separate signals for the LEDs via the 4017 IC. This then drives the corresponding LEDs in the various rows.
Soldering the MatrixChoosing the right LEDs is one of the most important parts of this project. because choosing the right ones is very critical to the execution of this project. I recommend using 5mm diffused LEDs because they supply a decent amount of brightness and delivers a clear image.
Soldering the Arduino LED matrix is the tricky part, there are a lot of ways to do it and I will share my method with you. You need to connect all the positive leads of the LEDs in columns and the negative leads in rows. You can use the solder dot prototyping board for soldering the LEDs on it. Push the LEDs through the adjacent holes on the board. Use the circuit figure below to connect the Arduino LED matrix together. Then, take the positive lead of the first LED and bend it down to the other LEDs and solder the pins which touch each other. Next, take the last lead that you soldered and bend it again down and repeat till you have all the positive leads connected in the column. Snip off the extra length of the leads that you didn’t use.
Now a new dilemma is created. That is: connecting the negative pins in a row because you can’t bend them and solder like you did with the positive leads, as they will short each other. My method saves a lot of time and is simpler. The trick is to put some tape on the column's connections to isolate them from the negative pins. If you do that, you can bend the negative leads too and connect them like you did with the positive ones. They won't short each other because they will be isolated. The circuit for the Arduino LED matrix is as shown below:
Via a resistor, you have to connect each column to the Arduino (pins 0-7). The reset pin of the 4017 goes to pin 8 on the Arduino and the clock pin goes to pin 9 on the Arduino.
Multiplexing for the Arduino LED Matrix
What is multiplexing?
It is basically a way to split information into little pieces and send it one by one. This way you can save a lot of pins on the Arduino and keep your program simple. In our case we split the image that we want to display into 10 pieces (10 rows). We want to scan the rows of the matrix (light up one row at a time) and send info from the Arduino to the columns. All the columns are positives of the LEDs and the rows are negatives. So if the first row is connected to ground and we send a signal to the first column, it will only light the first LED in the row. To get a good display, we need to scan the rows very fast, so fast that the human eye thinks that all of the rows are connected at the same time.
Why IC 4017?
To control this Arduino LED matrix, 4017 IC is the best way to do it. Here’s a good site to learn the basics of this IC: 4017 IC. The 4017 decade counter helps us with the multiplexing. This IC basically scans the rows of the matrix (lights up one row at a time). In our case, we want to connect the rows to ground, but the 4017 provides a signal output and cannot ground the LEDs. To solve this little problem we need to use a transistor with a resistor.
The 4017 has 10 output pins, so we need 10 resistors and 10 transistors. We connect the 1K resistors to the outputs of the 4017 and its other end to the base of the transistor as shown in the circuit figure at the top of this page. Next, we connect the collectors of the transistor to the LED rows and the emitter to the ground. You can also use a BC547 NPN transistor.
Programming the Arduino LED Matrix
I have written a little program that scrolls text and added all the letters and numbers to it too. I used ports for my program because it saves space and is easier to handle.
If you don’t know how to work with ports on the Arduino, I recommend going on the Arduino website to learn a few basic things before you start. Here’s the link: Arduino port manipulation.
Port control is really easy, check out the figure above as an example. The red dots indicate the LEDs which are ON and the white as OFF. In the first row of the matrix, to turn the 2nd and 7th LEDs ON, we give a command to Arduino port: B01000010. Here the 2nd and 7th bits are "1", which in turn turns the LED ON. "B" indicates to the Arduino that the port is an output port. We do this exercise for all the rows and finally, we will get a smiley face in the lights like in the figure above.
If you want to make your own images, I made a little Excel tool that will make writing images a lot easier. You can find it in the zip folder which I have attached at the end.
Please share your projects so that we can work together! Here's the video demo Arduino LED matrix: