|
#include <Timer.h>
Timer t;
const int PA[]={22,23,24,25,26,27,28,29};
const int PD[]={14,15,16,17,18,19,20,21};
const int LedPin_BIT = 13;
const int RL1_BIT = 2;
const int RL2_BIT = 3;
const int RL3_BIT = 4;
const int RL4_BIT = 5;
const int RL5_BIT = 6;
const int RL6_BIT = 7;
const int RL7_BIT = 8;
void setup() {
pinMode(LedPin_BIT, OUTPUT);
t.oscillate(LedPin_BIT,200, LOW);
pinMode(RL1_BIT, OUTPUT);
pinMode(RL2_BIT, OUTPUT);
pinMode(RL3_BIT, OUTPUT);
pinMode(RL4_BIT, OUTPUT);
pinMode(RL5_BIT, OUTPUT);
pinMode(RL6_BIT, OUTPUT);
pinMode(RL7_BIT, OUTPUT);
digitalWrite(RL1_BIT, HIGH);
digitalWrite(RL2_BIT, HIGH);
digitalWrite(RL3_BIT, HIGH);
digitalWrite(RL4_BIT, HIGH);
digitalWrite(RL5_BIT, HIGH);
digitalWrite(RL6_BIT, HIGH);
digitalWrite(RL7_BIT, HIGH);
for (int L = 0; L<=7; L++) {
pinMode(PA[L], OUTPUT);
pinMode(PD[L], OUTPUT);
digitalWrite(PA[L], LOW);
digitalWrite(PD[L], LOW);
digitalWrite(LedPin_BIT, LOW);
delay(50);
digitalWrite(LedPin_BIT, HIGH);
delay(50);
}
Serial.begin(19200);
Serial.println("ok");
}
void loop() {
t.update();
delay(1000); // 延时 1000 毫秒
for (int L = 0; L<=7; L++) {
digitalWrite(PA[L], HIGH);
digitalWrite(PD[L], HIGH);
}
delay(1000);
for (int L = 0; L<=7; L++) {
digitalWrite(PA[L], HIGH);
digitalWrite(PD[L], HIGH);
}
Serial.println("ok2");
}
代码如上,本来是测试两组LED亮灭的,发现 串口输出一直都是
ok
ok
ok
ok
ok
ok
ok
ok
ok
ok
ok
ok
ok
,这明显是setup函数一直在循环输出呀,新人初学,请求各位大神帮忙解答。
|
|