LED Matrix With Arduino
Intro: LED Matrix With Arduino
Hola , I am Javier from Makespace Madrid. Last week we organised a meetup to play with LED matrixes and Arduinos. This was part of "La noche de la electrónica con Jameco"
This instructable is based on the workshop. It uses one single LED matrix and shows how to switch its LEDs on/off and how to display ASCII characters.
A future instructable will show how to work with mulitple LED matrixes connected together.
This instructable is based on the workshop. It uses one single LED matrix and shows how to switch its LEDs on/off and how to display ASCII characters.
A future instructable will show how to work with mulitple LED matrixes connected together.
STEP 1: Components
For this example, you need the following components:
- Arduino Uno board
- MAX7219 Red Dot Matrix Module
- 5 jumper wires F/M (female/male)
Although this instructable uses an Arduino Uno board, you can use other Arduino (compatible) boards
You can find the matrix module at many online stores (e.g. http://dx.com/p/max7219-dot-matrix-module-w-5-dupont-lines-184854). This includes a 8x8 LED matrix (red colour), a MAX7219 chip to control the LEDs, header PINs and sockets, one 10KOhm resistor, a 100nF capacitor, a 10uF electrolic capacitor and a PCB where everything is connected together. You can purchase the module already soldered and mounted or just the components. Up to you;-)
If you want to learn the low level details, you should check this article at arduino playground.
IMPORTANT: The LED matrix is common cathode. This module does not work with common anode matrixes.
- Arduino Uno board
- MAX7219 Red Dot Matrix Module
- 5 jumper wires F/M (female/male)
Although this instructable uses an Arduino Uno board, you can use other Arduino (compatible) boards
You can find the matrix module at many online stores (e.g. http://dx.com/p/max7219-dot-matrix-module-w-5-dupont-lines-184854). This includes a 8x8 LED matrix (red colour), a MAX7219 chip to control the LEDs, header PINs and sockets, one 10KOhm resistor, a 100nF capacitor, a 10uF electrolic capacitor and a PCB where everything is connected together. You can purchase the module already soldered and mounted or just the components. Up to you;-)
If you want to learn the low level details, you should check this article at arduino playground.
IMPORTANT: The LED matrix is common cathode. This module does not work with common anode matrixes.
STEP 2: Arduino Library
The LED matrix is controlled from the MAX7219 chip through an Arduino Library.
This instructable is based on the LEDControl library. You can read a very clear and detailed tutorial about this library at arduino playground.
The nice thing about this library is that you can connect up to 8 matrixes together to build larger displays (more about this in a future instructable).
The LedControl library has been updated with several new methods to simplify the display of characters and strings. The new version of the library is available here (chose your preferred compression format: zip or rar)
To install the library in your Arduino IDE:
- uncompress the library file that you just downloaded
- make sure that you close all the open windows of the Arduino IDE
- look for the libraries folder inside the folder where you installed the Arduino IDE (see picture)
- copy the uncompressed LedControlMS folder (the folder with all its content) inside the libraries folder
If everything worked fine, you can now open the Arduino IDE again. If you go to File-> Examples, there should be a tab named LedControlMS with four files inside it.
This instructable is based on the LEDControl library. You can read a very clear and detailed tutorial about this library at arduino playground.
The nice thing about this library is that you can connect up to 8 matrixes together to build larger displays (more about this in a future instructable).
The LedControl library has been updated with several new methods to simplify the display of characters and strings. The new version of the library is available here (chose your preferred compression format: zip or rar)
To install the library in your Arduino IDE:
- uncompress the library file that you just downloaded
- make sure that you close all the open windows of the Arduino IDE
- look for the libraries folder inside the folder where you installed the Arduino IDE (see picture)
- copy the uncompressed LedControlMS folder (the folder with all its content) inside the libraries folder
If everything worked fine, you can now open the Arduino IDE again. If you go to File-> Examples, there should be a tab named LedControlMS with four files inside it.
STEP 3: Wiring
Once you have installed the library, it is time to connect the LED matrix to the Arduino board.
The LED Matrix module has two sets of male header PINs. In this instructable you will only use the input PIN headers that are located closer to the MAX 7219 chip.
There are five PINs that must be connected through F/M jumper wires to the corresponding Arduino PINs:
LED Matrix Arduino Colour of wire in picture
VCC 5V Red
GND GND Black
DIN D12 Yellow
CS D10 White
CLK D11 Blue
You can check the colours of the wires in the pictures in case that you have any doubt.
The LED Matrix module has two sets of male header PINs. In this instructable you will only use the input PIN headers that are located closer to the MAX 7219 chip.
There are five PINs that must be connected through F/M jumper wires to the corresponding Arduino PINs:
LED Matrix Arduino Colour of wire in picture
VCC 5V Red
GND GND Black
DIN D12 Yellow
CS D10 White
CLK D11 Blue
You can check the colours of the wires in the pictures in case that you have any doubt.
STEP 4: Example Sketch
The original LedControl library can handle both 7-segments LED displays as well as LED matrixes. This instructable only uses the LED matrix methods.
The updated library created for the Makespace Madrid workshop defines an alphabet/font of characters that can be displayed in the LED matrixes. It also includes two new methods, writeString and displayChar. You can see practical examples of how the different methods work in the MakeSpace_LEDMatrix example sketch distributed with the library.
To open this sketch, in the Arduino IDE menu go to File-> Examples->LedControlMS->MakeSpace_ LEDMatrix
You can now upload the sketch to your arduino and see what the example does.
Note1: if the version of your Arduino IDE is "quite" old (0.x) you will need to change the extension of the arduino sketches distributed with the library. Change the extension of the files from .ino to .pde (MakeSpace_ LEDMatrix.ino -> MakeSpace_ LEDMatrix.pde). Your IDE should be able to read and open this file (probably you need to close all the Arduino IDE windows, change the file extensions and then restart the IDE again).
Note2: Before uploading the sketch, make sure that you have selected the right card and serial port for your arduino
The updated library created for the Makespace Madrid workshop defines an alphabet/font of characters that can be displayed in the LED matrixes. It also includes two new methods, writeString and displayChar. You can see practical examples of how the different methods work in the MakeSpace_LEDMatrix example sketch distributed with the library.
To open this sketch, in the Arduino IDE menu go to File-> Examples->LedControlMS->MakeSpace_ LEDMatrix
You can now upload the sketch to your arduino and see what the example does.
Note1: if the version of your Arduino IDE is "quite" old (0.x) you will need to change the extension of the arduino sketches distributed with the library. Change the extension of the files from .ino to .pde (MakeSpace_ LEDMatrix.ino -> MakeSpace_ LEDMatrix.pde). Your IDE should be able to read and open this file (probably you need to close all the Arduino IDE windows, change the file extensions and then restart the IDE again).
Note2: Before uploading the sketch, make sure that you have selected the right card and serial port for your arduino
STEP 5: And Play!
If everything worked fine, your LED matrix will start a sequence of actions switching on and off leds and displaying different characters.
You can now map the code in the example sketch to the actions in the matirx. Update the sketch to do new things and experiment with the library methods.
To help you, the PDF file below has some hints about how the LEDs, rows and columns are numbered and coded in the LEDControl library.
Don't be afraid to make errors! That is the fastest way to learn.
Enjoy!
You can now map the code in the example sketch to the actions in the matirx. Update the sketch to do new things and experiment with the library methods.
To help you, the PDF file below has some hints about how the LEDs, rows and columns are numbered and coded in the LEDControl library.
Don't be afraid to make errors! That is the fastest way to learn.
Enjoy!
81 Comments
robmotes1977 3 years ago
sri1999 5 years ago
Does this work with arduino uno board?
I tried the code ,uploaded it and then all the leds glowed.But it didn't show up as shown in the video above
WachidA1 5 years ago
Hi Tumaku,,,nice post...
May I ask you for help, If I want to use 4 set dot matrix and want to display text character, which sketch must to change, please?
I want to use this char
PROGMEM const unsigned char CH[] = {
3, 8, B0000000, B0000000, B0000000, B0000000, B0000000, // space
1, 8, B1011111, B0000000, B0000000, B0000000, B0000000, // !
3, 8, B0000011, B0000000, B0000011, B0000000, B0000000, // "
5, 8, B0010100, B0111110, B0010100, B0111110, B0010100, // #
Thanks....
MalcolmO5 6 years ago
#define NBR_MTX 2 // Why do I have to say "2" when there is only 1 matrix in my setup?
tumaku 6 years ago
Thanks Malcolm for noticing this bug!
I used the same sketch for another project with multiple matrices and I forgot to set NBR_MTX back to "1". Anyway, since the code only references one matrix (the one with index "0") the sketch is still working without any problem.
gooleim 6 years ago
I CAN'T FIND THE CODE!?
tumaku 6 years ago
There is a link in step 2 to compressed files in zip and rar format.
NoahP5 8 years ago
I am only getting two leds showing at once. I have checked for bridges and there are none. Can anyone help me here?
NoahP5 8 years ago
I am now getting more LEDs on at once but no distinguishable letters.
Attila_FIN 7 years ago
Hello, Most probably you fixed the LED matrix on the wrong side of the PCB.
It might be soldered on the CHIP side of the PCB.
MrMonk 8 years ago
I had the same /similar problem. the reason was that the MAX7219 was wrong inserted. I just removed it and inserted it in the other way round. Then it works!
tumaku 8 years ago
Sorry for the late response.
Not sure what is wrong, but I suggest to check three points:
- Are you providing enough power (miliamps) to the matrix?
- Have you double/triple checked that the wires are properly connected?
- Are you using a common cathode matrix? (the code does not work if the matrix is common anode)
goldenshuttle 7 years ago
nice work. Will this code run on USB attiny85 ?
TomK32 7 years ago
Sure it does. The ATTiny85 has plenty of pins for this. Even though it has only eight.
https://www.instructables.com/id/V-USB-ATtiny85-Pro...
https://halfbyteblog.wordpress.com/2015/11/29/usin...
D6equj5 7 years ago
tumaku 7 years ago
LED Matrix Arduino Colour of wire in picture
VCC 5V Red
GND GND Black
DIN D12 Yellow
CS D10 White
CLK D11 Blue
You can remap them for your ProMicro by updating their values in the following line of the sketch:
LedControl lc=LedControl(12,11,10, NBR_MTX);
trancor 7 years ago
Hey Tumaku, thanks for your post! This helped me out a ton when I first started out with my 8x8 Matrix.
I've linked to your instructables in an INO I made to make it easier to animate moving animations on the MAX7219 8x8 LED Matrix. I think I need to comment more of the code here, but the basics are there.
https://github.com/ProcStack/Arduino/tree/master/L...
Here's what the animation looks like (Sorry, it might be a little loud.)
tumaku 7 years ago
Cool animations!
suyogd9 7 years ago
can i get code or any information for respective project ?
tumaku 7 years ago
Code and explanation is available in Step 2