【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百二十:P6全彩LED模组 16X32显示屏单元板 P6-RGB-16X32-8S
室内全彩8扫电子屏(HX-P6-16X32-A)
项目程序之三:点与线的简单控制
- /*
- 【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
- 实验二百二十:P6全彩LED模组 16X32显示屏单元板 P6-RGB-16X32-8S
- 室内全彩8扫电子屏(HX-P6-16X32-A)
- 项目程序之三:点与线的简单控制
- */
-
- #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);
- }
复制代码
|