LED 8x8的程序在Arduino Uno中不起作用。我没有使用pinMode()方法为LED指定引脚输出。我用的是"LedControl“的方法
规格销:
"lc=LedControl(4,6,5,1);" 用于设置引脚的。为什么?
#include "LedControl.h"
/*Now we need a LedControl to work with.
pin 4 is connected to the DataIn
pin 5 is connected to the CLK
pin 6 is connected to LOAD / CS
We only have a single MAX7219 */
LedControl lc=LedControl(4,6,5,1);
/* we always wait a bit between updates of the display */
unsigned long delaytime=500;
void setup() {
/* The MAX72XX is in power-saving mode on startup,
we have to do a wakeup call */
lc.shutdown(0,false);
lc.setIntensity(0,8);
lc.clearDisplay(0);
}
void loop() {
lc.setIntensity(0,8);
single();
lc.clearDisplay(0);
}
/* This function will light up every Led on the matrix. The led will blink along with the row-number. row number 4 (index==3) will blink 4 times etc. */
void single() {
for(int row=0;row<8;row++) {
for(int col=0;col<8;col++) {
delay(50);
lc.setLed(0,row,col,true);
delay(50);
for(int i=0;i<col;i++) {
lc.setLed(0,row,col,false);
delay(50);
lc.setLed(0,row,col,true);
delay(50);
}
}
}
}发布于 2015-08-22 22:58:29
LedControl库在后台使用pinMode使LED更易于控制。当您将值赋给LedControl时,它会自动使用pinMode,它作为pinMode(pin, OUTPUT|INPUT)操作。
https://stackoverflow.com/questions/32161434
复制相似问题