Controlling MAX7219 Led Matrix Using Arduino

by Lisleapex Blog in Circuits > Arduino

159 Views, 2 Favorites, 0 Comments

Controlling MAX7219 Led Matrix Using Arduino

Circuit.png

In this tutorial, we will learn how to control the MAX7219 Led Matrix using Arduino by displaying a simple text.

Supplies

MAX7219.png

Arduino UNO (or any other Arduino)

LED Matrix. We will use the FC-16 module which has four cascaded 8×8 LED matrix displays and a built-in MAX7219 LED driver for each display.

Jumper wires

Visuino Program: Download Visuino

Circuit

Circuit.png

Connect LED matrix pin [VCC] to Arduino pin [5V]

Connect LED matrix pin [GND] to Arduino pin [GND]

Connect LED matrix pin [DIN] to Arduino digital pin [11]

Connect LED matrix pin [CS] to Arduino digital pin [10]

Connect LED matrix pin [CLK] to Arduino digital pin [13]

Start Visuino and Select Arduino UNO Board Type

Start Visuino and select Arduino UNO board type.png

To start programming the Arduino you will need to install the Arduino IDE from here: https://www.arduino.cc/.


Please note that there are some serious bugs in Arduino IDE 1.6.6. Make sure you install version 1.6.7 or higher or this tutorial will not work! If you have not already followed the steps in this tutorial to set up the Arduino IDE to program the Arduino UNO! Visuino: https://www.visuino.eu also needs to be installed. Launch Visuino and click the "Tools" button on the Arduino component in Visuino (Figure 1) as shown in the first picture When the dialog box appears, select "Arduino UNO"

Add Components in Visuino

Add components in Visuino.png

Added "Clock Generator" component

Added "Text Value" component

Added "Counter" component

Added "Integer Multi-Source"

Added "Maxim LED Display Controller SPI MAX7219/MAX7221" component

In the Visuino Settings Component

In the Visuino Settings component.png

Select " Counter1 " and in the properties window set the Max>Value to 0 and the Min>Value to -170 Note: -170 is the distance on X (the length of the text), the text will go from left to right, you can play with this number to get the right length Select " TextValue1 " and set the " Value " (this is the text you want to display on the LED matrix): ARDUINO LED MATRIX PROJECT


Select " LedController1 " and in the properties window select " Pixel Groups " and click on the 3 dots. In the "PixelGroups" window drag "2D Graphics" from the right to the left Select the left "2D Graphics1" and in the properties window set: - "Height" to 8 - "Mirror Horizontal" to true - "Orientation" up - "Reverse Horizontal" to True - "Reverse Vertical" to False - "Width" to 32 - Select the "Elements" window drag "Fill Screen" to the left, expand "Text" and drag "Text Field" to the left. Select "Text Field 1" and in the properties window set "Wrap" to false, select "X" and click on the "Pin" icon and select "Integer SinkPin" << see image Close all windows

Select "LedController1" and in the properties window set "Intensity" to 0.1 <

Select "ClockGenerator1" and in the properties window set "Frequency" to: 5

Select "IntegerMultiSource1" and in the properties window set "Output Pins" to: 3

In the Visuino Connect Component

In the Visuino Connect component.png

Connect "ClockGenerator1" pin [Out] to "Counter1" pin [In]

Connect "Counter1" pin [Out] to IntegerMultiSource1 pin [In]

Connect "IntegerMultiSource1" pin [0] to "LedController1" > Text Field1 > X

Connect "IntegerMultiSource1" pin [1] to "LedController1" > Fill Screen 1 > Clock

Connect "IntegerMultiSource1" pin [2] to "TextValue1" pin [Clock]

Connect "TextValue1" pin [Out] to "LedController1" > Text Field1 > In

Connect "LedController1" pin [Chip Select] to Arduino digital pin [10]

Connect "LedController1" pin [Out SPI] to Arduino pin [SPI In]

Generate, Compile and Upload Arduino Code

Generate, compile and upload Arduino code.png

In Visuino, click on the Build tab at the bottom, make sure the correct port is selected and click on the Compile/Build and Upload button.

Play

If you power the Arduino UNO module, the LED matrix will start displaying text from left to right.


Congratulations! You have completed your project using Visuino

Troubleshooting

In my case, when powering the Arduino, the LED Matrix flickered and the text was not fully displayed. This is because the MAX7219 chip is very sensitive to any voltage disturbance.


To fix this, I added a 47uf electrolytic capacitor between the LED Matrix VCC(+) and GND(-), making sure to connect the capacitor correctly, + on (VCC) and - on (GND)