Microcontroller Tutorials

Arduino, Raspberry Pi, PIC, Beaglebone Resources

How to Use the MAX7219 Cascaded Dot Matrix Module

With the 8 x 8 LEDs in a dot matrix, you can create quite several different characters and graphics. Imagine what you can do if you have a MAX7219 cascaded dot matrix module.

Introduction to Dot Matrices

A dot matrix is an array of LEDs controllable by addressing rows and columns.

Cascaded dot matrix


For example, if we want to turn on the top right LED, we apply a high voltage at pin 9 and a low voltage at pin 16.


The number of pins to use makes it hard for the dot matrix to be connected directly to a microcontroller. Thus, there is a need for drivers such as the MAX7219.

The MAX7219 is a serial-input common-cathode display driver. This IC package usually drives common-cathode seven segment displays but people found a way to also use it with dot matrices. More information on how to use the MAX7219 is on its datasheet.

Cascaded Dot Matrix

The cascaded dot matrix module connects four dot matrices in a daisy chain. Through POV, the human eye is tricked so that the LEDs seem to light up simultaneously. In reality, the LEDs are lit up one at a time at a rate that the human eye cannot catch up.


The cascaded dot matrix has five pins: VCC, GND, CS, DIN, and CLK. Experienced microcontroller guys will immediately know that these pins are SPI pins.

Cascaded dot matrix pinout

The dot matrix is removable and when removed will show each MAX7219 display driver underneath.

Removing a dot matrix reveals MAX7219

The LED Matrix Driver Library

Before we can use the cascaded dot matrix with an Arduino, we need a dedicated library. There are several libraries available but I found the LEDMatrixDriver library to be the easiest one to use.

The library uses the Arduino’s hardware SPI. Thus, the module must be connected to an Arduino (UNO or Nano) as follows:

Fritzing diagram of cascaded dot matrix connected to Arduino UNO


Dot Matrix Module Arduino UNO or Nano
VCC 5V
GND GND
DIN 11
CS 9
CLK 13

The library contains a number of example sketches. One of them is the MarqueeText example which displays a scrolling text.


To change the text, we can edit line 18. For example, I changed that line to this:

Note that only capital letters are possible with this sketch. This is because of the defined fonts in lines 33 to 93.

Marquee text example

Creating Graphics

The same library can create graphics in a 4 x 8 x 8-pixel arrangement. The example DrawSprite sketch demonstrates this.

The example DrawSprite sketch displays a running stick figure.

Running stick figure on dot matrix


The stick figure is from six array of bytes corresponding to six frames or movements. Edit the following lines if you want to create your own sprite.


You can also set which dot in the matrix you want to light up using the setPixel() function. The example SetPixel sketch shows this:

The SetPixel sketch turns on each dot starting from the top left down to the bottom right then turns them off again following the same sequence.

Set pixel example


To create your own font, or graphics, visit this site. I hope you found this tutorial helpful!

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.