• Worldwide Shipping

  • 24/7 Customer Support

  • FAQ
  • Worldwide Shipping

  • 24/7 Customer Support

  • FAQ

HUM: LED MATRIX 8x8 with the MAX7219 driver

You are a beginner with Croduino. Or electronics? A specific module caught your eye, but you do not know how to use it? Do not worry, HUM is here for you! How to Use Module (HUM) is a blog tutorials series by e-radionica where you will find all you need in order to begin working with your favorite module. Tutorials include: technical characteristics, work principle, instructions on how to connect the module with Croduino and the basic code. Everything else is left to your imagination.

Introduction

Whether you are a beginner with Croduino or have already made several of your own projects using Croduino breadboard, you've certainly met the LED and the way it works. The LED is an indispensable part of various simple (and advanced) projects. Surely, many beginners are wondering what if we want to use more LEDs at the same time? Do we need to connect each LED to a separate digital output of the Croduino board? What if we do not have enough Croduino pins for all the LEDs needed in our project? You can find the solution to this and many other problems using the 8x8 LED matrix with the MAX7219 driver.

 

Characteristics:
• Voltage: 5V
• LED color: Crvena
• Driver: MAX7219
• Dimensions: 54mm x 32mm
• Simple connection and control using only 5 pins

How does it work?

LED matrix 8x8 is a system of 64 interconnected LEDs that are arranged in 8 columns and 8 rows. They are ideal for displaying letters, numbers, symbols, text, etc. Each column of the matrix contains the LED cathodes that are inside that column, while each row contains the LED anodes of that row. To illuminate a particular LED, you need to connect a specific column in which the selected LED is located to the logical zero (LOW) and the row in which the LED is located to the logical one (HIGH). If we want to illuminate more LEDs at the same time, we connect the rows of selected LEDs to the logical one, while we connect the columns in which they are located to the logical zero. So for the control of all 64 LEDs, we need a total of 16 pins, i.e. digital outputs of the microcontroller. That is too many necessary pins that can be used for connection of some other sensors or actuators. In order to solve this problem, we will connect the LED matrix to the MAX7219 driver.


MAX7219 is a compact serial input/output controller that interconnects microcontrollers with 7-segment LED displays or LED matrices. It contains a BCD decoder, a multiplexer, and an 8x8 static RAM that stores each digit for the LED matrix display. Driver control is possible via SPI communication. One of the advantages of this driver is that MAX7219 can activate each column and row for a very short time. This allows fast switching through the columns and rows that the human eye perceives as a continuous light, and thus we get the impression that more LEDs are illuminated at the same time. Using the MAX7219 driver, we can control the LED matrix with only 5 connectors, which greatly simplifies the use and the connection of the LED matrix to the microcontroller. In addition to that, everything is located on a single board, making it easy to use the module itself. Another advantage of this module is the ability to connect multiple modules into a series so that we can manage multiple LED matrices, with the same number of connectors on the microcontroller, at once.

How to connect the module with Croduino?

Connecting the module and Croduino is very simple. For the control and managing, the module contains 5 connectors, and those are:
VCC (5V) – serves for power supplying the board,
GND (Ground) – serves for power supplying the board,
DIN (Serial-Data Input) – input data channel,
DOUT (Serial-Data Output) – output data channel,
CS (Chip-Select Input) – the pin that allows chip activation and                                                          • CLK (Serial-Clock Input) - serial input.

VCC needs to be connected to + 5V pin of the Croduino board, and GND to the GND pin. DIN of the module needs to be connected to the D12 pin, the CLK pin of the module to the D10 and the CS to the D11 pin. If you want to connect more 8x8 LED Matrix modules to the MAX7219 driver, you need to connect the VCC, GND, CLK and CS connectors of the second module to the same connectors of the first module and connect the DIN pin of the second module to the DOUT of the first one. When connecting several LED Matrix modules, pay attention to the current that you provide to the VCC inputs of all modules, because there is a possibility that Croduino will not be able to provide enough power to power supply all LED matrices (usually if 5 or more modules are connected). In this case, it is necessary to connect the LED Matrix module and the Croduino to a common 5V power source that provides more than 2A current.

Arduino library and code

There are many different libraries that make programming the LED matrix module with the Max7219 driver easier. For this example, we have chosen the "LedControl.h" library. The program code below shows how to program the Croduino board to display the heart animation.

#include "LedControl.h"
LedControl lc=LedControl(12,10,11,1); // (DIN pin, CLK pin, CS pin, the number of LED matrices)
unsigned long delayTime=800; // pause between image displays
// the field that shows one image on the LED matrix
byte srce1[] =
{
B01100110, //values of the first LED matrix row; 1 - turned on, 0 - turned off LED
B11111111, //values of the second LED matrix row
B11111111, //values of the third LED matrix row
B11111111, //values of the fourth LED matrix row
B01111110, //values of the fifth LED matrix row
B00111100, //values of the sixth LED matrix row
B00011000, //values of the seventh LED matrix row
B00000000 //values of the eight LED matrix row
};
// the field that shows another image on the LED matrix
byte srce2[] =
{
B01100110,
B10011001,
B10000001,
B10000001,
B01000010,
B00100100,
B00011000,
B00000000
};
void setup()
{
lc.shutdown(0,false); // turn on the LED matrix
lc.setIntensity(0,1); // set the light intensity (0-15)
lc.clearDisplay(0); // clear the LED matrix display
}
void prikazi_srce1()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(0,i,srce1[i]); // display of the elements field, row by row
}
}
void prikazi_srce2()
{
for (int i = 0; i < 8; i++)
{
lc.setRow(0,i,srce2[i]);
}
}
void loop()
{
prikazi_srce1(); //show the first image
delay(delayTime); //wait for delayTime milliseconds
prikazi_srce2(); //show the second image
delay(delayTime); //wait for delayTime milliseconds
}
Leave a Reply