Overview
In this guide, we will learn how to use the 8×32 MAX7219 Dot Matrix LED Display with Arduino. The 8×32 LED matrix module with MAX7129 LED driver is compatible with Arduino Board & other microcontrollers. An 8×32 LED matrix has 256 LEDs (Light Emitting Diodes) which are arranged in the form of a matrix as 8 rows and 32 columns. Hence it is named an 8×32 Dot Matrix LED.
Using the Parola and MAX72xx library we can generate different rolling LED patterns such as numbers, alphabets, scrolling text, symbols, emojis, etc. Apart from this, we can also display some sensor data like DHT11/DHT22 on this display. Let’s see some examples in this post.
Bill of Materials
You can buy the following components from Amazon in order to use this module.
| S.N. | Components | Quantity | Purchase Links |
|---|---|---|---|
| 1 | Arduino UNO Board | 1 | Amazon | AliExpress |
| 2 | 8x32 MAX7219 Dot Matrix LED Display | 1 | Amazon | AliExpress |
| 3 | DHT22 Sensor | 1 | Amazon | AliExpress |
| 4 | Jumper Wires | 1 | Amazon | AliExpress |
| 5 | Power Supply | 1 | Amazon | AliExpress |
Dot Matrix LED Display
LED matrices are available in different styles like single color, dual color, multi-color, or RGB LED matrix. They are also available in different dimensions like 5 x 7, 8 x 8, 16 x 16, 8 x 32, 32 x 32 etc.
This 8×32 LED Matrix Display is a cluster of 4 single modules, internally connected. These modules can also be separated, because every module carries the same Maxim MAX7219 chip, and comes with the same power and data connection.
Pin Configuration
The 8×8 LED matrix have 8 positive terminal & 8 negative terminals. The 8 negative terminals are 8 columns & 8 positive terminal are 8 rows.
The 4 8X8 LED Matrix are connected to each other via the MAX7219 Pins.
MAX7219 LED Driver IC
The LED matrix can be driven in two ways. They are parallel (where each row or column is sent with parallel data) and serial (where the data is sent serially and an IC is used to convert this serial data into parallel data).
MAX7219 is a common cathode display driver with serial input and parallel output. It is used to interface microprocessors and microcontrollers with 64 individual LEDs. The 8 x 8 LED matrix is connected to the MAX 7219. The data input is received from the Arduino board to the MAX7219.
Interfacing 8×32 MAX7219 Dot Matrix LED Display with Arduino
Now let us see how we can interface 8×32 MAX7219 Dot Matrix LED Display with Arduino Board to display some texts and numbers.
This display draws a lot of current, therefore we need to run the module from the external power supply instead of the 5V supply from the Arduino board. You need to use an external power adapter of 5V, 3A rating connected to the 5V & GND Pin of the Arduino Board.
As the MAX7219 module requires a lot of data transfer, it needs to get connected to the hardware SPI pins on a microcontroller. For Arduino boards such as the UNO/Nano those pins are digital 13 (SCK), 12 (MISO), 11 (MOSI), and 10 (SS).
Connect the CLK, CS, DIN Pin of 8×32 LED Dot Matrix Display to Arduino digital pin 13, 10, 11.
In this guide we are using FC-16 MAX7219 Module. If you want to daisy-chain multiple displays to create a larger display, connect the DOUT of the first display to the DIN of the next display. VCC, GND, CLK, and CS will all be shared between displays.
Library Installation
Controlling the MAX7219 module is a complex task and requires a lot of lines of code. Fortunately, the MD_Parola library is available to remove those complexities so that we can issue simple commands to control the display.
To install the library navigate to Sketch > Include Library > Manage Libraries. From the Search, options look for ‘max72xx’ and click on install.
This MD_MAX72XX library is a hardware-specific library that handles lower-level functions. It needs to be paired with MD_Parola Library to create many different text animations like scrolling and sprite text effects. Install this library as well.
Source Code/Program for Text/Number Printing
Copy the following code and paste it on your Arduino IDE.
|
1 2 |
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW //#define HARDWARE_TYPE MD_MAX72XX::GENERIC_HW |
From these lines, select the hardware type. In our case the hardware type is FC16_HW.
|
1 |
myDisplay.displayScroll("How To Electronics", PA_CENTER, PA_SCROLL_LEFT, 200); |
In these lines type any text and numbers you want to display on the LED Display.
Now you can upload the code to the Arduino Board.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
#include <MD_Parola.h> #include <MD_MAX72xx.h> #include <SPI.h> #define HARDWARE_TYPE MD_MAX72XX::FC16_HW //#define HARDWARE_TYPE MD_MAX72XX::GENERIC_HW #define MAX_DEVICES 4 #define CS_PIN 10 MD_Parola myDisplay = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES); void setup() { myDisplay.begin(); myDisplay.setIntensity(4); myDisplay.displayClear(); myDisplay.displayScroll("How To Electronics", PA_CENTER, PA_SCROLL_LEFT, 200); } void loop() { if (myDisplay.displayAnimate()) { myDisplay.displayReset(); } } |
Output Test
I want to display the scrolling text “How To Electronics”. The text will scroll like this.
Apart from this you can display any text or numbers like this.
Displaying DHT22 Humidity Temperature Sensor Value
Now let us interface the DHT22 Temperature & Humidity Sensor with Arduino & display the sensor value on 8×32 Dot Matrix LED Display.
Connect the DHT22 Sensor VCC, GND & Output pin to 5V, GND & D7 of Arduino.
Source Code/Program
This code requires a header file called Font7Seg.h for compilation. Download this file and copy it in the main sketch folder.
Now you can copy this code to the Arduino main sketch and upload it to the Arduino.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
/* * Use of MAX72XX, DS1307 and DTH22 components to * print some information on the display. * * for more examples: * https://github.com/MajicDesigns/MD_Parola/tree/main/examples * https://github.com/MajicDesigns/MD_MAX72XX/tree/main/examples */ // Header file includes #include <MD_Parola.h> #include <MD_MAX72xx.h> #include <DHT.h> #include <SPI.h> #include <Wire.h> #include "Font7Seg.h" #define HARDWARE_TYPE MD_MAX72XX::FC16_HW #define MAX_DEVICES 4 // Define the number of displays connected #define CLK_PIN 13 // CLK or SCK #define DATA_PIN 11 // DATA or MOSI #define CS_PIN 10 // CS or SS #define SPEED_TIME 75 // Speed of the transition #define PAUSE_TIME 0 #define MAX_MESG 20 // These are for the temperature #define DHTPIN 6 #define DHTTYPE DHT22 #define TIMEDHT 1000 char szTime[9]; // mm:ss\0 char szMesg[MAX_MESG + 1] = ""; float humidity, celsius, fahrenheit; uint8_t degC[] = { 6, 3, 3, 56, 68, 68, 68 }; // Deg C uint8_t degF[] = { 6, 3, 3, 124, 20, 20, 4 }; // Deg F uint8_t clear = 0x00; uint32_t timerDHT = TIMEDHT; DHT dht(DHTPIN, DHTTYPE); // Hardware SPI connection MD_Parola P = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES); uint8_t decToBcd(uint8_t value) { return ((value / 10 * 16) + (value % 10)); } uint8_t bcdToDec(uint8_t value) { return ((value / 16 * 10) + (value % 16)); } void getTemperature() { // Wait for a time between measurements if ((millis() - timerDHT) > TIMEDHT) { // Update the timer timerDHT = millis(); humidity = dht.readHumidity(); celsius = dht.readTemperature(); fahrenheit = dht.readTemperature(true); if (isnan(humidity) || isnan(celsius) || isnan(fahrenheit)) { Serial.println("Failed to read from DHT sensor!"); return; } } } void setup(void) { Wire.begin(); P.begin(2); P.setInvert(false); P.setZone(0, MAX_DEVICES - 4, MAX_DEVICES - 1); P.setZone(1, MAX_DEVICES - 4, MAX_DEVICES - 1); P.displayZoneText(0, szMesg, PA_CENTER, SPEED_TIME, 0, PA_PRINT, PA_NO_EFFECT); P.addChar('$', degC); P.addChar('&', degF); dht.begin(); } void loop(void) { static uint32_t lastTime = 0; // Memory (ms) static uint8_t display = 0; // Current display mode static bool flasher = false; // Seconds passing flasher getTemperature(); P.displayAnimate(); if (P.getZoneStatus(0)) { switch (display) { case 0: // Temperature deg Celsius P.setPause(0, 1000); P.setTextEffect(0, PA_SCROLL_LEFT, PA_SCROLL_UP); display++; dtostrf(celsius, 3, 1, szMesg); strcat(szMesg, "$"); break; case 1: // Temperature deg Fahrenheit P.setTextEffect(0, PA_SCROLL_UP, PA_SCROLL_DOWN); display++; dtostrf(fahrenheit, 3, 1, szMesg); strcat(szMesg, "&"); break; case 2: // Humidity P.setTextEffect(0, PA_SCROLL_DOWN, PA_SCROLL_LEFT); display++; dtostrf(humidity, 3, 0, szMesg); strcat(szMesg, "%UR"); break; } P.displayReset(0); // Rest zone zero } } |
Output Test
The 8×32 Dot Matrix LED Display along with Arduino will display the temperature humidity data.
This is how you can use the 8×32 MAX7219 Dot Matrix LED Display with Arduino Board to display scrolling text and numbers.























3 Comments
Help. Im new to Arduino and would like to use this sketch on an ESP32 as I want to display a temperature value remotely from another ESP32 using ESP NOW. I have tried to convert this sketch without the clock but i am having difficulty with it not running. I am not sure about the Font7seg.h file?
How do we know what our hardware type is? I am fairly new to arduino, and my brain is small. Does it say the hardware type on the Matrix/7219 chip?
uint8_t degC[] = { 6, 3, 3, 56, 68, 68, 68 }; // Deg C
uint8_t degF[] = { 6, 3, 3, 124, 20, 20, 4 }; // Deg F
plz explain