Introduction
A dot matrix display is a display device used to display information on machines, clocks, railway departure indicators and many other devices requiring a simple display device of limited resolution. Even if the 8x8 RGB led dot matrix is commonly used in lots of applications, but it require too much digital pins to drive it. And the software is too complex also.
The 8x8 LED RGB matrix module aimed to solve these problems. Directly drive the 8x8 RGB matrix module via the SPI serial interface. It works with 3-wire digital pins and the hardware SPI interface. The RGB matrix module from DFRobot is Daisy-chainable connection design - vertically and horizontally at the same time. And the high speed data transmission design improves its' display refresh rate. So it's possible to assemble a big RGB Matrix screen.
Unit comes with a Red/Green/Blue full color LED Matrix assembled with a RGB Matrix Backpack Controller. Certainly,it directly support Arduino. And the library supplied is helpful to drive it much easier.
Attention: Due to the restrictions, currently only supports 7 colors display, maximum 3x3 cascade!
Specification
- Power supply: 5v
- Max current comsuption: 300mA
- Communications interface: SPI (3 digital pins or hardware SPI interface)
- LED color: RGB tri-color LEDs
- 8x8 dot matrix display assembled
- Useful both for industrial and commercial information displays as well as for hobbyist human–machine interfaces
- Directly support Arduino
- Simplify the driving way
- Daisy-chainable connection design - vertically and horizontally at the same time
- High speed data transmission design to improve the display refresh rate
- Size: 60x60mm
Connection
Connection with Arduino UNO
Connection with interface shield
Multiple modules connected
AT Command
When you have uploaded the sketch, you can control the module by AT command via serial port. Baud rate: 115200
AT+clear() Clear screen
AT+set_cur(0) Initialize the cursor position
AT+print(123,0) Display "123" on top layer, and it doesn't support letter
AT+add_layer() Add a new layer
AT+set_cur(0,8) Reset the the cursor position.
AT+put_char(0,8,65,1,0,3,1) Rotate display "A" at (0,8) color: red+green
AT+put_char(8,8,66,1,0,5,1) Rotate display "B" at (8,8) color: red+blue
AT+move(4,1,0) Move layer 0 right
AT+move(3,1,0) Move layer 0 left
AT+move(1,1,1) Move layer 1 up
AT+move(2,1,1) Move layer 1 down
AT+remove_layer(1) Remove layer 1
Sample Code (IDE V1.0)
Sample Code 1x1
/*****************************************************************************
* Copyright: ChengDu Geeker Tech. Co., Ltd. (DFRobot)
* File name: hello_matrix.pde
* Description: test the function of rgb matrix
* Author: wanghui_CD
* Version: V1.0
* Date: 2012.06.21
* History: none
*****************************************************************************/
#include <rgb_matrix.h>
#include <SPI.h>
unsigned long time=0;
unsigned int tick_100ms = 0;
unsigned char counter=0;
#define N_X 1
#define N_Y 1
/*
//Interface shield ShiftOut connector
#define DATA_PIN 9
#define CLK_PIN 3
*/
//Hardware SPI
#define DATA_PIN 11
#define CLK_PIN 13
#define LATCH_PIN 8
rgb_matrix M = rgb_matrix(N_X, N_Y, DATA_PIN, CLK_PIN, LATCH_PIN);
unsigned char cmd[50]={0},cmd_num=0;
unsigned char tmp = 'A';
unsigned char st=0;
void setup()
{
Serial.begin(115200);
delay(200);
}
/*************************************************************************
* Description:
* display callback function
* Receive AT comand via serial,and then run the right comand.
* This function can be run in sweep interval.
* Reduce delay time at function tail if screen blink.
* Increase delay time at function tail if screen shows a double image.
* Param: none
* Retval: none
**************************************************************************/
void hook(void)
{
int i = 0;
unsigned long enter_time,exit_time;
enter_time = micros();
if((++counter)%10 == 0)
{
if(millis() - time >= 100)
{
time = millis();
tick_100ms ++;
M.move(UP,1,0);
if(tick_100ms%2 == 0)
{
}
if(tick_100ms%5 == 0)
{
M.clear();
M.put_char(0,0,tmp+(st++)%26,1,MULTIPLY,RED << (st%3),TOP_LAYER);
}
if(tick_100ms%10 == 0)
{
}
if(tick_100ms%20 == 0)
{
}
if(tick_100ms%50 == 0)
{
}
}
}
if(Serial.available())
{
cmd[cmd_num++] = Serial.read();
if((cmd_num>=2) && (cmd[cmd_num-1] == 0x0a) && (cmd[cmd_num-2] == 0x0d))
{
M.at_cmd(cmd);
cmd_num = 0;
}
}
exit_time = micros();
if(enter_time < exit_time)
{
if(exit_time - enter_time < 500)
{
delayMicroseconds(500 - (exit_time-enter_time));
}
}
}
/*************************************************************************************
* Description:
* loop function
* Display function must be called.
* If you wanna do something after display be called,
* you should give display function a parameter which is a pointer to a function.
* Param: none
* Retval: none
**************************************************************************************/
void loop()
{
M.set_cur(0,0);
M.display(hook);
}
Sample Code 4x2
/*****************************************************************************
* Copyright: ChengDu Geeker Tech. Co., Ltd.
* File name: hello_matrix.pde
* Description: test the function of rgb matrix
* Author: wanghui_CD
* Version: V1.0
* Date: 2012.06.21
* History: none
*****************************************************************************/
#include <rgb_matrix.h>
#include <SPI.h>
unsigned long time=0;
unsigned int tick_100ms = 0;
unsigned char counter=0;
#define N_X 4
#define N_Y 2
/*
//Interface shield ShiftOut connector
#define DATA_PIN 9
#define CLK_PIN 3
*/
//Hardware SPI
#define DATA_PIN 11
#define CLK_PIN 13
#define LATCH_PIN 8
rgb_matrix M = rgb_matrix(N_X, N_Y, DATA_PIN, CLK_PIN, LATCH_PIN);
unsigned char data_buf[N_X*N_Y*8*3]={0};
/*
×ÝÏòÈ¡Ä££¬¸ßλÔÚÉÏ¡£
ÏÈ×óºóÓÒ£¬ÏÈÉϺóÏ¡£
*/
const char ni[] =
{
0x02,0x04,0x1F,0xE0,0x02,0x04,0x18,0xF0,
0x10,0x13,0x10,0x10,0x14,0x18,0x00,0x00,
0x00,0x00,0xFF,0x00,0x00,0x10,0x20,0xC2,
0x01,0xFE,0x00,0x80,0x60,0x30,0x00,0x00
};
const char hao[] =
{
0x08,0x08,0x0F,0xF8,0x08,0x0F,0x01,0x41,
0x41,0x41,0x47,0x49,0x51,0x63,0x01,0x00,
0x02,0x44,0xA8,0x10,0x28,0xC6,0x00,0x00,
0x02,0x01,0xFE,0x00,0x00,0x00,0x00,0x00
};
unsigned char cmd[50]={0},cmd_num=0;
void setup()
{
Serial.begin(115200);
delay(200);
}
/*************************************************************************
* Description:
* display callback function
* Receive AT comand via serial,and then run the right comand.
* This function can be run in sweep interval.
* Reduce delay time at function tail if screen blink.
* Increase delay time at function tail if screen shows a double image.
* Param: none
* Retval: none
**************************************************************************/
void hook(void)
{
int i = 0;
unsigned long enter_time,exit_time;
enter_time = micros();
//delayMicroseconds(300);
if((++counter)%10 == 0)
{
if(millis() - time >= 100)
{
time = millis();
tick_100ms ++;
if(tick_100ms%2 == 0)
{
}
if(tick_100ms%5 == 0)
{
}
if(tick_100ms%10 == 0)
{
M.move(LEFT,1,0);
}
if(tick_100ms%20 == 0)
{
M.move(RIGHT,1,1);
}
if(tick_100ms%50 == 0)
{
}
}
}
if(Serial.available())
{
cmd[cmd_num++] = Serial.read();
if((cmd_num>=2) && (cmd[cmd_num-1] == 0x0a) && (cmd[cmd_num-2] == 0x0d))
{
M.at_cmd(cmd);
cmd_num = 0;
}
}
exit_time = micros();
if(enter_time < exit_time)
{
if(exit_time - enter_time < 300)
{
delayMicroseconds(300 - (exit_time-enter_time));
}
}
}
/*************************************************************************************
* Description:
* loop function
* Display function must be called.
* If you wanna do something after display be called,
* you should give display function a parameter which is a pointer to a function.
* Param: none
* Retval: none
**************************************************************************************/
void loop()
{
M.add_layer(data_buf);
M.put_HZ(0,0,ni,MULTIPLY,RED+GREEN,TOP_LAYER);
M.put_HZ(16,0,hao,MULTIPLY,GREEN,TOP_LAYER+1);
M.display(hook);
}