HUM: LED MATRIX 8X8 WITH THE MAX7219 DRIVER

You are a beginner with Dasduino. 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 soldered 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 Dasduino and the basic code. Everything else is left to your imagination.
INTRODUCTION
Whether you are a beginner with Dasduino or have already made several of your own projects using Dasduino 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 Dasduino board? What if we do not have enough Dasduino pins for all the LEDs needed in our project? You can find the solution to this and many other problems using the 8×8 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 8×8 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 8×8 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 DASDUINO?
Connecting the module and Dasduino 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 Dasduino 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 8×8 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 Dasduino 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 Dasduino 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 Dasduino board to display the heart animation.