Arduino UNO R4 - LED Matrix

This tutorial instructs you how to use Arduno UNO R4 with external LED matrix display modules. In detail, we will learn:

Then, you can simply modify the code for other LED matrices like the 16x8 or 64x8 LED matrix.

Arduino UNO R4 LED Matrix

If you want to learn about how to use Arduino R4 with on-board LED Matrix, please refer to Arduino UNO R4 - Built-in LED Matrix

Hardware Preparation

1×Arduino UNO R4 WiFi
1×Arduino UNO R4 Minima (Alternatively)
1×USB Cable Type-C
1×FC-16 LED Matrix 32x8
1×FC-16 LED Matrix 8x8
1×Jumper Wires
1×DC Power Jack
1×5V Power Adapter for Arduino UNO R4
1×(Recommended) Screw Terminal Block Shield for Arduino UNO R4
1×(Recommended) Breadboard Shield For Arduino UNO R4
1×(Recommended) Enclosure For Arduino UNO R4

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables.

Overview of LED Matrix

LED Matrix display

Various types of LED Matrix exist. The MAX7219-based LED matrix is commonly used with Arduino UNO R4. This LED matrix includes several features:

  • The basic component of an LED matrix is called a block.
  • Each block contains an 8x8 grid of LEDs, totaling 64 LEDs, and is controlled by a MAX7219 chip.
  • There are two main types of blocks: the generic module and the FC-16 module.
  • An LED matrix can have just one block or be expanded by connecting multiple blocks together like a chain.
  • You can purchase LED matrices that already have multiple blocks connected, such as 4-block or 8-block configurations.
  • Alternatively, you can buy individual blocks and connect them yourself to create an LED matrix of the size you need.
  • In your Arduino UNO R4 program, you must specify the size of the LED matrix you're using.

Pinout

LED Matrix Pinout

A LED Matrix is made up of one or more blocks. Each block has two sets of pins:

  • Group of Input Pins:
    • VCC: Link this to the 5V.
    • GND: Link this to the GND.
    • DIN: This is the Data pin. Connect it to the SPI MOSI pin on the Arduino UNO R4.
    • CS: Chip Select. Connect this to any digital pin on the Arduino UNO R4.
    • CLK: Clock pin. Connect this to the SPI CLK pin on the Arduino UNO R4.
  • Group of Output Pins:
    • VCC: Connect this to VCC on the subsequent module.
    • GND: Connect this to GND on the subsequent module.
    • DOUT: Data Out. This connects to the DIN pin on the next module.
    • CS: Connect this to CS on the subsequent module.
    • CLK: Connect this to CLK on the subsequent module.

Wiring Diagram

If the LED matrix consists of just one block:

  • Connect the groups of input pins to the Arduino UNO R4.
  • Leave the groups of output pins unconnected.
The wiring diagram between Arduino UNO R4 8x8 LED matrix FC-16

This image is created using Fritzing. Click to enlarge image

The wiring diagram between Arduino UNO R4 8x8 LED matrix generic

This image is created using Fritzing. Click to enlarge image

If the LED matrix comes already assembled into multiple blocks:

  • Connect the group of input pins to the Arduino UNO R4.
  • Leave the group of output pins unconnected.
The wiring diagram between Arduino UNO R4 LED matrix display

This image is created using Fritzing. Click to enlarge image

If you assemble the LED matrix from several parts:

  • Connect the input pin group of the first block to the Arduino UNO R4.
  • Connect the output pin group of each block to the input pin group of the following block.
  • Leave the output pin group of the last block unconnected.
Arduino UNO R4 32x8 LED matrix wiring FC-16 diagram

This image is created using Fritzing. Click to enlarge image

Arduino UNO R4 32x8 LED matrix wiring generic diagram

This image is created using Fritzing. Click to enlarge image

The display uses a lot of power, up to 1 ampere at maximum brightness.

  • Avoid using the 5V pin on the Arduino UNO R4 for power.
  • Instead, connect an external 5V power supply. The Arduino UNO R4 and the LED matrix can both be powered by the same 5V adapter.

The Arduino UNO R4 connects to the LED matrix using SPI pins.

  • Use pin 13 (SCK) and 11 (MOSI) on Arduino UNO R4. If using a different Arduino UNO R4 board, look at the official guide for the same SPI pins.
  • You can use any other pin for Pin 3 (CS).

How To Program For LED Matrix

Controlling the LED matrix can be challenging. Luckily, there are libraries that simplify this task. Here are the steps to program an Arduino UNO R4 to control the LED matrix.

  • Include libraries:
#include <MD_Parola.h> #include <MD_MAX72xx.h>
  • Choose the type of hardware you are using: GENERIC_HW or FC16_HW.
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
  • Determine how many LED blocks are used. For instance, a 4-in-1 LED matrix contains 4 blocks.
#define MAX_DEVICES 4
  • Set the pin attached to the CS pin on the LED matrix. For example, use pin D9.
#define CS_PIN 9
  • Make a new version of the MD_Parola class for the LED matrix display.
MD_Parola ledMatrix = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
  • Set up the code in the setup() function.
void setup() { ledMatrix.begin(); // Initialize the LED matrix ledMatrix.setIntensity(0); // Set the display brightness (range 0-15) ledMatrix.displayClear(); // Clear the display screen }
  • Show text, numbers, and animated effects: see the following part.

Arduino UNO R4 - LED Matrix Code

The code provided is for a 32x8 FC-16 LED matrix display with four blocks. However, it can be modified for other sizes like 8x8, 16x8, 64x8, and so on.

/* * This Arduino UNO R4 code was developed by newbiely.com * * This Arduino UNO R4 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-r4/arduino-uno-r4-led-matrix */ #include <MD_Parola.h> #include <MD_MAX72xx.h> #define HARDWARE_TYPE MD_MAX72XX::FC16_HW #define MAX_DEVICES 4 // 4 blocks #define CS_PIN 9 // The Arduino UNO R4 pin connected to the CS pin of LED matrix // create an instance of the MD_Parola class MD_Parola ledMatrix = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES); void setup() { ledMatrix.begin(); // initialize the object ledMatrix.setIntensity(0); // set the brightness of the LED matrix display (from 0 to 15) ledMatrix.displayClear(); // clear LED matrix display } void loop() { ledMatrix.setTextAlignment(PA_LEFT); ledMatrix.print("Left"); // display text delay(2000); ledMatrix.setTextAlignment(PA_CENTER); ledMatrix.print("Center"); // display text delay(2000); ledMatrix.setTextAlignment(PA_RIGHT); ledMatrix.print("Right"); // display text delay(2000); ledMatrix.setTextAlignment(PA_CENTER); ledMatrix.setInvert(true); ledMatrix.print("Invert"); // display text inverted delay(2000); ledMatrix.setInvert(false); ledMatrix.print(1234); // display number delay(2000); }

Detailed Instructions

Follow these instructions step by step:

  • If this is your first time using the Arduino Uno R4 WiFi/Minima, refer to the tutorial on setting up the environment for Arduino Uno R4 WiFi/Minima in the Arduino IDE.
  • Connect the Arduino Uno R4 board to the led matrix according to the provided diagram.
  • Connect the Arduino Uno R4 board to your computer using a USB cable.
  • Launch the Arduino IDE on your computer.
  • Select the appropriate Arduino Uno R4 board (e.g., Arduino Uno R4 WiFi) and COM port.
  • In the Arduino IDE, click on the Libraries icon on the left sidebar.
  • Search for "MD_Parola" and locate the MD_Parola library.
  • Click the Install button.
Arduino UNO R4 MD_Parola library
  • You need to install the MD_MAX72XX library. Please click the Install All button.
Arduino UNO R4 MD_MAX72XX library
  • Copy the code above and open it using Arduino IDE.
  • Click the Upload button in Arduino IDE to upload the code to Arduino UNO R4.
  • Watch the display on the LED matrix.

Arduino UNO R4 LED Matrix Code – Scrolling Text

When you need to show a long message on a LED matrix display and it is too long to fit, you can use the scrolling text effect.

This Arduino UNO R4 code demonstrates how to make a message scroll across the LED matrix display.

/* * This Arduino UNO R4 code was developed by newbiely.com * * This Arduino UNO R4 code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-uno-r4/arduino-uno-r4-led-matrix */ #include <MD_Parola.h> #include <MD_MAX72xx.h> #define HARDWARE_TYPE MD_MAX72XX::FC16_HW #define MAX_DEVICES 4 // 4 blocks #define CS_PIN 9 // The Arduino UNO R4 pin connected to the CS pin of LED matrix // create an instance of the MD_Parola class MD_Parola ledMatrix = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES); void setup() { ledMatrix.begin(); // initialize the object ledMatrix.setIntensity(0); // set the brightness of the LED matrix display (from 0 to 15) ledMatrix.displayClear(); // clear led matrix display ledMatrix.displayScroll("Hello", PA_CENTER, PA_SCROLL_LEFT, 100); } void loop() { if (ledMatrix.displayAnimate()) { ledMatrix.displayReset(); } }

To see more text effects, go to MD_Parola Library Reference.

Video Tutorial

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!