Arduino Nano 33 IoT - LED Matrix

A LED matrix display, also called LED display or dot matrix display, is used a lot. In this tutorial, you will learn:

After that, you can easily change the code for other LED displays like a 16x8 LED display or a 64x8 LED display.

Arduino Nano 33 IoT LED dot matrix

Hardware Preparation

1×Arduino Nano 33 IoT
1×Micro USB Cable
1×FC-16 LED Matrix 32x8
1×FC-16 LED Matrix 8x8
1×Generic LED Matrix 8x8
1×Breadboard
1×Jumper Wires
1×Optionally, DC Power Jack
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano

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

There are many types of LED matrix displays. When using the Arduino Nano 33 IoT, the LED matrix that uses the MAX7219 chip is very popular. This MAX7219 LED matrix has these features:

  • The basic part of an LED matrix is called a block.
  • Each block has an 8x8 LED grid (64 LEDs) and a MAX7219 chip that controls them.
  • There are two common types of blocks: the generic module and the FC-16 module.
  • An LED matrix can be made of one block or many blocks connected together.
  • You can buy a ready-made LED matrix that has many blocks (for example, a 4-in-1 or an 8-in-1).
  • You can also buy individual blocks and connect them yourself to make an LED matrix of the size you want.
  • You must set the size of the LED matrix in the Arduino Nano 33 IoT code.

Pinout

LED Matrix Pinout

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

  • Input Pins Group:
    • VCC: Connects to 5V.
    • GND: Connects to ground.
    • DIN: This is the Data pin. Connect it to any digital pin on the Arduino Nano 33 IoT.
    • CS: This stands for Chip Select. Connect it to any digital pin on the Arduino Nano 33 IoT.
    • CLK: This is the Clock pin. Connect it to any digital pin on the Arduino Nano 33 IoT.
  • Output Pins Group:
    • VCC: Connects to the VCC pin of the input group on the next module.
    • GND: Connects to the ground (GND) pin of the input group on the next module.
    • DOUT: This is the Data Out pin. Connect it to the DIN pin of the input group on the next module.
    • CS: Connects to the CS pin of the input group on the next module.
    • CLK: Connects to the CLK pin of the input group on the next module.

Wiring Diagram

If the LED screen is built as one piece:

  • Attach the input pin groups to the Arduino Nano 33 IoT.
  • Leave the output pin group disconnected.
The wiring diagram between Arduino Nano and 33 IoT 8x8 LED matrix FC-16

This image is created using Fritzing. Click to enlarge image

The wiring diagram between Arduino Nano and 33 IoT 8x8 LED matrix generic

This image is created using Fritzing. Click to enlarge image

If the LED matrix is made of several pre-built blocks:

  • Connect the group of input pins to the Arduino Nano 33 IoT.
  • Leave the group of output pins not connected.
The wiring diagram between Arduino Nano and 33 IoT LED matrix display

This image is created using Fritzing. Click to enlarge image

If you built the LED matrix from several blocks by yourself:

  • Attach the first block's input pins to the Arduino Nano 33 IoT.
  • Connect the output pins of each block to the input pins of the next block.
  • Leave the output pins of the last block unconnected.
Arduino Nano 33 IoT 32x8 LED matrix wiring FC-16 diagram

This image is created using Fritzing. Click to enlarge image

Because the screen uses a lot of power (up to 1 amp at full brightness):

  • Don't use the power from the Arduino Nano 33 IoT’s 5V pin.
  • Instead, use an external 5V power supply. Both the Arduino Nano 33 IoT and the LED matrix can get power from the same 5V adapter.

Because the Arduino Nano 33 IoT connects to the LED matrix using SPI pins.

  • Use D13 (SCK) and D11 (MOSI) on the Arduino Nano 33 IoT board.
  • You can change Pin D10 (CS) to any other pin you want.

How To Program For LED Matrix

Controlling the LED matrix is not simple. Luckily, there are libraries to help make it easier. Here is a simple guide on how to write Arduino Nano 33 IoT code to control the LED matrix.

  • Add libraries:
#include <MD_Parola.h> #include <MD_MAX72xx.h>
  • Choose the hardware you are using: GENERIC_HW or FC16_HW.
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
  • Count the number of LED blocks used. For example, a 4-in-1 LED matrix has 4 blocks.
#define MAX_DEVICES 4
  • Choose the pin that connects to the LED matrix's chip select (CS) pin. For example, use pin D10.
#define CS_PIN D10
  • Make a new MD_Parola object for the LED matrix display.
MD_Parola ledMatrix = MD_Parola(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
  • Write the instructions inside the setup() function:
void setup() { ledMatrix.begin(); // start the LED matrix object ledMatrix.setIntensity(0); // configure the LED matrix brightness (range: 0 to 15) ledMatrix.displayClear(); // clear the LED matrix display }
  • Show text, numbers, and animated effects. Check the next section.

Arduino Nano 33 IoT - LED Matrix Code

This code is made for a 32x8 FC-16 LED matrix display (4 parts). You can also change it easily to work with 8x8, 16x8, or 64x8 displays.

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-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 10 // The Arduino Nano 33 IoT pin connected to the CS pin of the 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 LED Matrix ledMatrix.setIntensity(15); // 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

If you are new to the Arduino Nano 33 IoT, be sure to check out our Getting Started with Arduino Nano 33 IoT tutorial. Then, follow these steps:

  • Connect the components to the Arduino Nano 33 IoT board as depicted in the diagram.
  • Use a USB cable to connect the Arduino Nano 33 IoT board to your computer.
  • Launch the Arduino IDE on your computer.
  • Select the Arduino Nano 33 IoT board and choose its corresponding COM port.
  • Click the Library Manager icon on the left side of the Arduino IDE.
  • Type MD_Parola in the search box and find the MD_Parola library.
  • Click the Install button.
Arduino Nano 33 IoT MD_Parola library
  • You may need to add the MD_MAX72XX library.
  • Click the Install All button to add the necessary files.
Arduino Nano 33 IoT MD_MAX72XX library
  • Copy the code above and open it in Arduino IDE.
  • Click the Upload button in Arduino IDE to send the code to your Arduino Nano 33 IoT.
  • Watch the LED matrix display light up.

Arduino Nano 33 IoT LED Matrix Code – Scrolling Text

If you want to show a long message that doesn't fit on an LED display, you can use a scrolling text effect.

Here is the Arduino Nano 33 IoT code that shows you how to scroll text on an LED display.

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-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 10 // The Arduino Nano 33 IoT pin connected to the CS pin of the 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(15); // set the brightness of the LED matrix display (from 0 to 15) ledMatrix.displayClear(); // clear led matrix display ledMatrix.displayScroll("Arduino Nano 33 IoT", PA_CENTER, PA_SCROLL_LEFT, 100); } void loop() { if (ledMatrix.displayAnimate()) { ledMatrix.displayReset(); } }

To see more text effects, please check out the MD_Parola Library Reference.

Video Tutorial

Learn More

※ 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!