- #include "LedControl.h"//库函数
-
- LedControl lc=LedControl(12,11,10,1);//定义点阵管引脚 :12(DataIn),11(CLK),10(LOAD)1(为后面所连接点阵管芯片数目)
- //给延时定义一个值
- unsigned long delaytime=100;
- unsigned long delaytime1=2000;
- void setup() {
- //设置省电模式(addr--需要设备号,status--true为开启省电模式 false为关闭)
- lc.shutdown(0,false);
- //设置对象第1个设备亮度为8
- lc.setIntensity(0,8);
- //对象为第1个设备清零
- lc.clearDisplay(0);
- }
- void writeArduinoOnMatrix() {
- /*
- 定义字模 */
- byte a[8]={B00010000,
- B11111110,
- B10010010,
- B10010010,
- B11111110,
- B00010000,
- B00010000,
- B00010000
- };
-
- /*
- 设置一行8个LED开关状态*/
- lc.setRow(0,0,a[0]);
- lc.setRow(0,1,a[1]);
- lc.setRow(0,2,a[2]);
- lc.setRow(0,3,a[3]);
- lc.setRow(0,4,a[4]);
- lc.setRow(0,5,a[5]);
- lc.setRow(0,6,a[6]);
- lc.setRow(0,7,a[7]);
- delay(delaytime1);
-
- lc.setRow(0,1,0);
-
- }
- void loop() {
- // put your main code here, to run repeatedly:
- writeArduinoOnMatrix();
- }
复制代码 发一个简单的代码 |