CONTROL LED MATRIX MAX7219 WITH ARDUINO

by RonFrtek in Circuits > Arduino

4102 Views, 4 Favorites, 0 Comments

CONTROL LED MATRIX MAX7219 WITH ARDUINO

LED matrix

In this tutorial we will learn how to control the MAX7219 Led matrix with Arduino by displaying a simple text.

Watch a demonstration video.

What You Will Need

VisuinoAdvrtisementM5Stack6.jpg
arduino.jpg
jumper-wires.jpg
  1. Arduino UNO (or any other Arduino)
  2. LED MATRIX. We are going to use the FC-16 module which has four casacaded 8×8 LED Matrix Displays and a built-in MAX7219 LED Driver for each display.
  3. Jumper wires
  4. Visuino program: Download Visuino

The Circuit

max7219-with-arduino-schematic.png
  1. Connect LED Matrix pin[VCC] to Arduino pin[5V]
  2. Connect LED Matrix pin[GND] to Arduino pin[GND]
  3. Connect LED Matrix pin[DIN] to Arduino digital pin[11]
  4. Connect LED Matrix pin[CS] to Arduino digital pin[10]
  5. Connect LED Matrix pin[CLK] to Arduino digital pin[13]

Note: Read also the part for Troubleshooting below

Start Visuino, and Select the Arduino UNO Board Type

FZCTLDCK36U3SD6.LARGE.jpg
F056F06K4USKVH1.LARGE.jpg

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

Please be aware that there are some critical bugs in Arduino IDE 1.6.6. Make sure that you install 1.6.7 or higher, otherwise this Instructable will not work! If you have not done follow the steps in this Instructable to setup the Arduino IDE to program Arduino UNO! The Visuino: https://www.visuino.eu also needs to be installed. Start Visuino as shown in the first picture Click on the "Tools" button on the Arduino component (Picture 1) in Visuino When the dialog appears, select "Arduino UNO" as shown on Picture 2

In Visuino Add Components

2020-01-14_11-47-47.jpg
2020-01-14_11-47-19.jpg
2020-01-14_11-46-50.jpg
2020-01-14_11-48-51.jpg
2020-01-14_11-48-22.jpg

  1. Add "Clock Generator" component
  2. Add "Text Value" component
  3. Add "Counter" component
  4. Add "Integer Multi Source"
  5. Add "Maxim LED Display Controller SPI MAX7219/MAX7221" component

In Visuino Set Components

2020-01-14_11-50-52.jpg
2020-01-14_11-51-16.jpg
2020-01-14_11-51-51.jpg
2020-01-14_11-52-13.jpg
2020-01-14_11-52-41.jpg
2020-01-14_11-53-04.jpg
2020-01-14_11-53-41.jpg
2020-01-14_11-54-03.jpg
2020-01-14_11-54-50.jpg
2020-01-14_11-54-33.jpg
2020-01-14_14-32-57.jpg
  1. Select "ClockGenerator1" and in the properties window set "Frequency" to: 5
  2. Select "Counter1" and in the properties window set Max>Value to 0 and Min>Value to -170

    Note: -170 is the distance on X (length of the text), that the text will travel from left to the right, you can play with this number to get the right length
  3. Select "IntegerMultiSource1" and in the properties window set "Output Pins" to: 3
  4. Select "TextValue1" and set the "Value" (This is the text you want to display on the LED Matrix): ARDUINO LED MATRIX PROJECT
    1. Select "LedController1" and in the properties window select "Pixel Groups" and click on the 3 dots.
      In the "PixelGroups" window drag "2D Graphics" from right side to the left side
      Select "2D Graphics1" on the left side and in the properties window set :
      - "Height" to 8
      - "Mirror Horizontal" to true
      - "Orientation" to goUp
      - "Reverse Horizontal" to True
      - "Reverse Vertical" to False
      - "Width" to 32
      - Select "Elements" and click on the 3dots

      In the "Elements" window drag "Fill Screen" to the left, expand "Text" and drag "Text Field" to the left side.
      Select "Text Field1" and in the properties window set "Wrap" to False, Select "X" and click on the "Pin" icon and select "Integer SinkPin" <<see the picture

      Close All windows
    2. Select "LedController1" and in the properties window set "Intensity" to 0.1 <

In Visuino Connect Components

2020-01-14_14-29-02.jpg
  1. Connect "ClockGenerator1" pin [Out] to "Counter1" pin[In]
  2. Connect "Counter1" pin [Out] to IntegerMultiSource1 pin [In]
  3. Connect "IntegerMultiSource1" pin[0] to "LedController1" > Text Field1 > X
  4. Connect "IntegerMultiSource1" pin[1] to "LedController1" > Fill Screen1 > Clock
  5. Connect "IntegerMultiSource1" pin[2] to "TextValue1" pin [Clock]
  6. Connect "TextValue1" pin[Out] to "LedController1" > Text Field1 > In
  7. Connect "LedController1" pin [Chip Select] to Arduino digital pin[10]
  8. Connect "LedController1" pin [Out SPI] to Arduino pin[SPI In]

Generate, Compile, and Upload the Arduino Code

2020-10-30_13-20-50.jpg

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

Play

If you power the Arduino UNO module, the LED Matrix will start to Display the text from left side to the right side.

Congratulations! You have completed your project with Visuino. Also attached is the Visuino project, that I created for this Instructable, you can download it here and open it in Visuino: https://www.visuino.eu

Troubleshooting

led-matric-capacitor.png

In my case When powering the Arduino the LED Matrix was blinking and the Text was not fully displayed. The reason for this was because MAX7219 chip is very sensitive to any voltage interference.

To solve that I added a 47uf electrolytic capacitor between the LED Matrix VCC(+) and GND(-), make sure you connect the capacitor right, + on (VCC) and - on the (GND)