Example Code for Arduino-Character Display

The article provides an example code for character display using Arduino, including hardware and software setup, a wiring diagram, and a sample code implementation with the DFRobot_RGBMatrix library for efficient character display.

Hardware Preparation

Software Preparation

Wiring Diagram

DFR0472 32x32 RGB LED Matrix Panel (4mm Pitch) Connection Diagram

warning_yellow.png Note: It needs an external power supply, the USB is only 5V@500mA, not enough power.

16P Interface Diagram

Other Preparation Work

Control signal pin connected to MEGA2560:
R1-> 24 G1-> 25 B1-> 26
R2-> 27 G2-> 28 B2-> 29
HA-> A0 HB-> A1 HC-> A2 HD-> A3 HE-> A4
OE-> 9 LAT-> 10 CLK-> 11
GND-> GND
Power Interface:
-5V -> +5V DC power supply positive
-5V -> +5V DC power supply positive
GND-> DC power supply negative
GND-> DC power supply negative

Sample Code


#include <DFRobot_RGBMatrix.h> // Hardware-specific library
#include <Wire.h>
#define OE    9
#define LAT   10
#define CLK   11
#define A     A0
#define B     A1
#define C     A2
#define D     A3
#define E     A4
#define WIDTH 64
#define HIGH  64
int a=0;
int b=16;
DFRobot_RGBMatrix matrix(A, B, C, D, E, CLK, LAT, OE, false, WIDTH, HIGH);

void setup()
{
  matrix.begin();
  // fill the screen with 'black'
  matrix.setTextSize(1);     // size 1 == 8 pixels high
  matrix.fillScreen(matrix.Color333(0, 0, 0));
  delay(500);
}

void loop()
{  byte i;
  if(a<=-64)
{a=64;
  }
  if(b<=-48)
{b=80;
  }
  matrix.fillScreen(0);//clear the screen
  matrix.setTextSize(2);//Set as 16*16 pixel
  matrix.setCursor(15, a);    // start at top left, with 8 pixel of spacing
  matrix.setTextColor(matrix.Color333(4, 0, 4));//
  matrix.println("DFR");//
  matrix.setTextSize(1);//Set as 8*8 pixel
  matrix.setCursor(12, b);
  matrix.println("DFROBOT");
  matrix.setTextSize(1);
  matrix.print("Let's joinhands witheach otherto create a future");
  delay(600);
  a=a-6;
  b=b-6;
}

Result

Character Display

Was this article helpful?

TOP