Random Nerd Tutorials

Guide for 8×8 Dot Matrix MAX7219 with Arduino + Pong Game


The dot matrix that we’re going to use in this guide is a 8×8 matrix which means that it has 8 columns and 8 rows, so it contains a total of 64 LEDs.

The MAX7219 chip makes it easier to control the dot matrix, by just using 3 digital pins of the Arduino board.

I think the best option is to buy the dot matrix with the MAX7219 chip as a module, it will simplify the wiring. You can check the dot matrix at Maker Advisor and find the best price.


You can control more than one matrix at a time. For that you just need to connect them to each other, as they have pins in both sides to extend the dot matrix.

Parts required

For this guide you’ll need:

You can use the preceding links or go directly to MakerAdvisor.com/tools to find all the parts for your projects at the best price!

Pin Wiring

You only need to connect 5 pins from the dot matrix to your Arduino board. The wiring is pretty straightforward:

Dot matrix pin Wiring to Arduino Uno
DIN Digital pin
CS Digital pin
CLK Digital pin

How to control the dot matrix with Arduino

For making it easier to control the dot matrix, you need to download and install in your Arduino IDE the LedControl library. To install the library follow these steps:

  1. Click here to download the LedControl library. You should have a .zip folder in your Downloads
  2. Unzip the .zip folder and you should get LedControl-master folder
  3. Rename your folder from LedControl-master to LedControl
  4. Move the LedControl folder to your Arduino IDE installation libraries folder
  5. Finally, re-open your Arduino IDE

Using the LedControl library functions

The easiest way to display something on the dot matrix is by using the functions setLed(), setRow() or setColumn(). These functions allow you to control one single led, one row or one column at a time.

Here’s the parameters for each function:

setLed(addr, row, col, state)

  • addr is the address of your matrix, for example, if you have just 1 matrix, the int addr will be zero.
  • row is the row where the led is located
  • col is the column where the led is located
  • state
    • It’s true or 1 if you want to turn the led on
    • It’s false or 0 if you want to switch it off

setRow(addr, row, value)


setCol(addr, column, value)


As previously stated, this matrix has 8 columns and 8 rows. Each one is indexed from 0 to 7. Here’s a figure for better understanding:


If you want to display something in the matrix, you just need to know if in a determined row or column, the LEDs that are on or off.

For example, if you want to display a happy face, here’s what you need to do:



Here’s a simple sketch that displays three types of faces: a sad face, a neutral face and a happy face. Upload the following code to your board:

In the end, you’ll have something like this:


Pong Game

The pong game that you’re about to try was created by Alessandro Pasotti.

For the pong game, you just need to add a 1k ohm potentiometer to the previous schematic. Assemble the new circuit as shown below:



Then, upload the following code to your Arduino board:


Here’s the final demonstration of me playing the pong game. Have fun!


Wrapping up

Have you ever used the dot matrix in your Arduino Projects?

Let me know by leaving a comment below.

If you like this post probably you might like my next ones (click here to subscribe my blog). Thanks for reading,


MicroPython Programming with ESP32/ESP8266 eBook

Learn how to program the ESP boards with MicroPython, including projects, tips, and tricks! The registrations are open for a limited time, so SIGN UP NOW »

Recommended Resources

Home Automation using ESP8266 »
Build IoT projects and home automation gadgets with the ESP8266 Wi-Fi module.

Build a Home Automation System »
Learn how to build a automation system using open-source hardware and software from scratch.

Arduino Step-by-Step Projects »
Build 25 cool Arduino projects with our course even with no prior experience!

Leave a Comment:

Add Your Reply

⏰ Registrations are open for "MicroPython Programming with ESP32 and ESP8266" eBook