【花雕动手做】有趣好玩的音乐可视化系列项目(30)--P6LED单元板
项目程序之一:点亮P6单元板——点与线的简单控制
/*
【花雕动手做】有趣好玩的音乐可视化系列项目(30)--P6LED单元板
项目程序之一:点亮P6单元板——点与线的简单控制
*/
#include <Adafruit_GFX.h> //核心图形库
#include <RGBmatrixPanel.h> //硬件特定库
#define CLK 8 //必须在这个端口上! (在Mega上使用PIN 11)
#define LAT A3
#define OE 9
#define A A0
#define B A1
#define C A2
//最后一个参数='false'禁用双屏障
RGBmatrixPanel matrix(A, B, C, CLK, LAT, OE, false);
void setup() {
matrix.begin(); //矩阵开始(启动)
}
void loop() {
//用红色在0,0处画一个像素
matrix.drawPixel(0, 0, matrix.Color333(7, 0, 0));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
//用绿色在31,0处画一个像素
matrix.drawPixel(31, 0, matrix.Color333(0, 7, 0));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
//用蓝色在31,15处画一个像素
matrix.drawPixel(31, 15, matrix.Color333(0, 0, 7));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
//用白色在0,15处画一个像素
matrix.drawPixel(0, 15, matrix.Color333(5, 5, 5));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
//用四种颜色在单元板四角各画一个像素
matrix.drawPixel(0, 0, matrix.Color333(7, 0, 0));
matrix.drawPixel(31, 0, matrix.Color333(0, 7, 0));
matrix.drawPixel(31, 15, matrix.Color333(0, 0, 7));
matrix.drawPixel(0, 15, matrix.Color333(5, 5, 5));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(0, 0, 31, 0, matrix.Color333(7, 0, 0));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(31, 0, 31, 15, matrix.Color333(0, 7, 0));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(0, 15, 31, 15, matrix.Color333(0, 0, 7));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(0, 0, 0, 15, matrix.Color333(5, 5, 5));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(0, 0, 31, 0, matrix.Color333(7, 0, 0));
matrix.drawLine(31, 0, 31, 15, matrix.Color333(0, 7, 0));
matrix.drawLine(0, 15, 31, 15, matrix.Color333(0, 0, 7));
matrix.drawLine(0, 0, 0, 15, matrix.Color333(5, 5, 5));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(0, 0, 31, 15, matrix.Color333(4, 7, 0));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(31, 0, 0, 15, matrix.Color333(4, 7, 0));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(0, 0, 31, 15, matrix.Color333(0, 7, 4));
matrix.drawLine(31, 0, 0, 15, matrix.Color333(0, 7, 4));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(0, 0, 31, 0, matrix.Color333(7, 0, 0));
matrix.drawLine(31, 0, 31, 15, matrix.Color333(0, 7, 0));
matrix.drawLine(0, 15, 31, 15, matrix.Color333(0, 0, 7));
matrix.drawLine(0, 0, 0, 15, matrix.Color333(5, 5, 5));
matrix.drawLine(0, 0, 31, 15, matrix.Color333(0, 7, 0));
matrix.drawLine(31, 0, 0, 15, matrix.Color333(0, 7, 0));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(0, 0, 31, 0, matrix.Color333(7, 0, 0));
matrix.drawLine(31, 0, 31, 15, matrix.Color333(7, 0, 0));
matrix.drawLine(0, 15, 31, 15, matrix.Color333(7, 0, 0));
matrix.drawLine(0, 0, 0, 15, matrix.Color333(7, 0, 0));
matrix.drawLine(0, 0, 31, 15, matrix.Color333(7, 0, 0));
matrix.drawLine(31, 0, 0, 15, matrix.Color333(7, 0, 0));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(0, 0, 31, 0, matrix.Color333(0, 7, 0));
matrix.drawLine(31, 0, 31, 15, matrix.Color333(0, 7, 0));
matrix.drawLine(0, 15, 31, 15, matrix.Color333(0, 7, 0));
matrix.drawLine(0, 0, 0, 15, matrix.Color333(0, 7, 0));
matrix.drawLine(0, 0, 31, 15, matrix.Color333(0, 7, 0));
matrix.drawLine(31, 0, 0, 15, matrix.Color333(0, 7, 0));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
matrix.drawLine(0, 0, 31, 0, matrix.Color333(0, 0, 7));
matrix.drawLine(31, 0, 31, 15, matrix.Color333(0, 0, 7));
matrix.drawLine(0, 15, 31, 15, matrix.Color333(0, 0, 7));
matrix.drawLine(0, 0, 0, 15, matrix.Color333(0, 0, 7));
matrix.drawLine(0, 0, 31, 15, matrix.Color333(0, 0, 7));
matrix.drawLine(31, 0, 0, 15, matrix.Color333(0, 0, 7));
delay(500);
matrix.fillScreen(matrix.Color333(0, 0, 0));
delay(500);
}
|