64x32 RGB LED Matrix With Arduino Mega




Introduction: 64x32 RGB LED Matrix With Arduino Mega

I enjoyed learning how to use LED matrix and addressable LEDs. They are a lot of fun when you figure out how it comes together. I have put together this tutorial explaining each steps in a simple and coherent manner for others to learn. So enjoy. Let me know if you have any questions.


RGB LED Matrix Module 64x32 pixel

Arduino Mega

Jumper Cables

USB Cable

USB power adapter with 2 input plugs

Step 1: The 64x32 RGB LED Matrix Module

Product Name
RGB LED Matrix Module P4 SMD2121 256x128mm 64x32 pixel

Pixel pitch: 4mm Individual

LED Size: SMD2121 2.1 x 2.1 mm

Indoor full colour Surface Mount Device

Max power consumption: 20W

Avg power consumption: 6.7W

Input voltage: DC5V

Step 2: Connecting the 64x32 LED Matrix Panel With Arduino Mega

Follow the diagram to connect pins to jumper cable connector.

You must attach a 5V power into the power input for the model to display properly. With power only from the board is not enough because some of the LED and colours do not turn on with full brightness.

Reference website: https://learn.adafruit.com/32x16-32x32-rgb-led-ma...

Another instruction with a hookup table - Lots of details. https://learn.adafruit.com/32x16-32x32-rgb-led-ma...

Step 3: Why Use Arduino Mega?

Arduino Mega has 256 KB of flash memory which is suitable for displaying many bitmaps on the LED matrix. The Arduino Uno has only 32KB of flash memory and is limited for use.

  • Arduino Uno - 32 KB Flash Memory
  • Arduino Mega - 256 KB Flash
  • ESP8266 D1 mini - 80 KiB
  • ESP-32S WROOM-32 - 4MiB Flash

Step 4: Programming for the LED Matrix Panel

Download and install Arduino software from the official website.

Install the RGB Matrix Panel library from Arduino library manager or GitHub website.

Install the Adafruit GFX Library from Arduino library manager or GitHub website.

Install Adafruit BusIO from Arduino library manager or GitHub website.

Open up example codes by going to File > Examples > RGB Matrix Panel > Pick from list.

Connect Arduino Mega to computer. Select the correct device and port. Upload and run the code.

Step 5: Setup RGB Matrix Panel Library Examples for the 64x32 Module

The examples in the library were made for smaller LED matrix modules. To run it on the 64x32 module we need to modify the code.

For all the examples in the library:

  • colorwheel_32x32
  • colorwheel_progmem_32x32
  • PanelGFXDemo_16x32
  • plasma_16x32
  • plasma_32x32
  • scrolltext_16x32
  • testcolors_16x32
  • testshapes_16x32
  • testshapes_32x32
  • testshapes_32x64

For each of the examples, the following changes needed to be made.
Add the line:

#define D A3

Modify the line:

RGBmatrixPanel *matrix = new RGBmatrixPanel(A, B, C, CLK, LAT, OE, true);

Adding D after C and 64 after true. The line should be like this.

RGBmatrixPanel *matrix = new RGBmatrixPanel(A, B, C, D, CLK, LAT, OE, true, 64);

Step 6: Convert Bitmap Images for the 64x32 LED Matrix Panel

Convert bitmap image to c file by going here: http://www.rinkydinkelectronics.com/t_imageconver...

Add the bitmap code to the top section.

Add the follow to “void loop() {}” function:

matrix->drawRGBBitmap(0, 0, (const uint16_t *)surface, 64, 32);



matrix->clear(); //Set image to black

This function is used to draw the bitmap.
matrix->drawRGBBitmap(x, y, bitmap, w, h);

  • x and y is the position on the board.
  • w and h is the width and height.
  • bitmap is the reference to the bitmap code at the top.

Get my final Arduino code here on GitHub:

Arduino Code on GitHub https://github.com/3DSurfacing/64x32-RGB-LED-Matr...

Be the First to Share


    • Tinkercad to Fusion 360 Challenge

      Tinkercad to Fusion 360 Challenge
    • Chocolate Challenge

      Chocolate Challenge
    • Frozen Treats Speed Challenge

      Frozen Treats Speed Challenge



    1 year ago


    I followed the exact same setup as you but unfortunately a lot of my rows are duplicated. I wrote a separate program for a timer, and the same row duplication issue occurred.

    I'd appreciate some help.

    187865176_144855427665662_8628156879389584309_n.jpg186268230_202679721575414_6746624853890698522_n.jpgArduino Issue.png

    1 year ago

    Hi thanks for this ace project. I like the way you have tidied the connections and mounted the Mega on a custom back plate.
    Any hints/suggestions on what the material or product used for backplate.
    Many thanks for your input


    1 year ago

    Hi, Please help. I am trying to get this to work with an ESP32. I reassigned most of the pins easily because the are shown in the code by #define CLK, LAT and OE, etc. But where are the R1, G1, B1, R2, G2, B2? I see the picture showing the pin numbers on your Mega, but not in the code. I need to change the numbers to these. I know they will because they work with the Adafruit Protomatter Library example doublebuffer_scrolltest:
    //Matrix pin assignments for ESP32
    uint8_t rgbPins[] = {25, 5, 15, 27, 26, 21};
    uint8_t addrPins[] = {22, 18, 23, 19};
    uint8_t clockPin = 13; // Must be on same port as rgbPins
    uint8_t latchPin = 16;
    uint8_t oePin = 17;

    Thank you


    Question 2 years ago on Step 2

    Hi, thank you for your detailed instructions. I recently bought 6 of some used outdoor RGB matrix panels, glued them up together and connected all the pins except D. Because HUB74A has no pin D. I used instructions from this link http://wiki.amperka.ru/projects:rgb-led-matrix-arduino. But my panels are 24x12 each, not 64x32. And I can not understand what I'm doing wrong, because the whole display 72x24 now shows letters split apart and doubled.
    Can you please help me with any suggestions?


    Answer 2 years ago

    Also what pins did you connect to the connector?


    Reply 2 years ago

    As shown in this table everything except D. And all the N's to GND


    Reply 2 years ago

    This table does not correspond with the connector in the picture. S to pin 8, OE to pin 9, L to pin 10.
    Try this line: RGBmatrixPanel(A, B, C, CLK, LAT, OE, true, 24)
    I am not sure what the S pin is. It is different to my board.
    Try RGBmatrixPanel(A, B, C, S, LAT, OE, true, 24)


    Answer 2 years ago

    In this line RGBmatrixPanel(A, B, C, CLK, LAT, OE, true).
    Only have RGBmatrixPanel(A, B, CLK, LAT, OE, true, 24)
    Try with 24 or not at the end.


    Reply 2 years ago

    Thank you for your response. It got worse with no C like here RGBmatrixPanel(A, B, CLK, LAT, OE, true, 24) with and without 24 at the end.


    Answer 2 years ago

    Also remove line
    #define C A2