Arduino UNO 控制 HUB75 接口全彩条屏单板
材料:
1 Arduino UNO R3
2 某宝买的全彩条屏(32*64):
RGB 条屏背面接口是 HUB75。
市面上有 HUB75 接口和 HUB75E 接口区别:
硬件连线:(全彩 RGB 单板需要单独供电 5V,1A 以上,否则颜色显示不正确)
Arduino 按 HUB75 接口连接如下图:(Arduino Mega:Mega2560)
Arduino 程序中的引脚定义(Arduino UNO 的第 8 脚)如下图:
程序一:全红、全绿、全蓝、全黑
将程序下载能看到 32*32 彩屏全红,全绿,全蓝,全黑。
注意:程序用到了两个库文件( RGB Matrix Panel library 和 Adafruit GFX Library),
文中最后附录有。
#include "Adafruit_GFX.h" // Core graphics library
#include "RGBmatrixPanel.h" // Hardware-specific library
//on the same PORT as the RGB data pins (D2-D7)
#define CLK 8 // MUST be on PORTB!
#define LAT 10
#define OE 9
#define A A0
#define B A1
#define C A2
#define D A3
// Last parameter = 'false' disable double-buffering
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false);
void setup() {
matrix.begin();
}
void loop() {
// fill the screen with red
//注释 matrix.fillRect(0, 0, 列, 行, matrix.Color333(red, Green, blue));
matrix.fillRect(0, 0, 32, 32, matrix.Color333(7, 0, 0));
delay(1000);
// fill the screen with green
matrix.fillRect(0, 0, 32, 32, matrix.Color333(0, 7, 0));
delay(1000);
// fill the screen with blue
matrix.fillRect(0, 0, 32, 32, matrix.Color333(0, 0, 7));
delay(1000);
// fill the screen with black
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(1000);
}
程序二:显示数字和任意 xy 坐标的任意颜色点
程序如下:
#include "Adafruit_GFX.h" // Core graphics library
#include "RGBmatrixPanel.h" // Hardware-specific library
//on the same PORT as the RGB data pins (D2-D7)
#define CLK 8 // MUST be on PORTB!
#define LAT 10
#define OE 9
#define A A0
#define B A1
#define C A2
#define D A3
// Last parameter = 'false' disable double-buffering
RGBmatrixPanel matrix(A, B, C, D, CLK, LAT, OE, false);
void setup() {
matrix.begin();
}
void loop() {
// draw some text!
matrix.setCursor(1, 0); // start at top left, with one pixel of spacing
matrix.setTextSize(1); // size 1 == 8 pixels high
// print each letter with a rainbow color
matrix.setTextColor(matrix.Color333(0,0,1));
matrix.print('1');delay(1000);
matrix.setTextColor(matrix.Color333(1,0,0));
matrix.print('2');delay(1000);
matrix.setTextColor(matrix.Color333(0,1,0));
matrix.print('3');delay(1000);
matrix.setTextColor(matrix.Color333(1,1,0));
matrix.print('4');delay(1000);
显示效果:
程序三:显示汉字
方法一: 描点法,利用函数 matrix.drawPixel(x, y, matrix.Color333( 0, 7, 0));delay(300);进行描
点写汉字;
方法二:思考中。。。 。。。
附录和参考网址:
参考网址:
1 写得比较详细,用来测试屏幕好坏,红绿蓝颜色全屏测试单板好坏
https://www.baidu.com/link?url=J_1xQR2K9m3tTTcmViOS_IlhQQBRpv1K-yO5Pk2g74U9Bdv
pzjfBCk2P3XPoKz0jnTOrkNeT_t9_BhQG-FE_5Rr-A4KX4-z6Ll76kbrtcbe&wd=&eqid=c55b9fc
500023931000000065c4ad6d4
2 两个库文件地址( RGB Matrix Panel library 和 Adafruit GFX Library):
https://learn.adafruit.com/32x16-32x32-rgb-led-matrix/test-example-code
https://github.com/adafruit/Adafruit-GFX-Library
https://github.com/adafruit/RGB-matrix-Panel