跑馬燈
This commit is contained in:
21
helloworld/helloworld.ino
Normal file
21
helloworld/helloworld.ino
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
int LED[] = {5, 6, 9, 10, 11};
|
||||||
|
int val[5] = {250, 150, 0, 150, 250};
|
||||||
|
int clk = 0;
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
// put your setup code here, to run once:
|
||||||
|
Serial.begin(9600);
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
pinMode(LED[i], OUTPUT);
|
||||||
|
digitalWrite(LED[i], HIGH);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
// put your main code here, to run repeatedly:
|
||||||
|
for (int i = 0; i < 5; i++) {
|
||||||
|
analogWrite(LED[i], val[(i + clk) % 5]);
|
||||||
|
}
|
||||||
|
clk += 1;
|
||||||
|
delay(200);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user