commit 4908c9a7a038ab4e9ba5e61319ffec74fac5cdee Author: wancat Date: Wed Mar 2 10:04:12 2022 +0800 跑馬燈 diff --git a/helloworld/helloworld.ino b/helloworld/helloworld.ino new file mode 100644 index 0000000..72a30eb --- /dev/null +++ b/helloworld/helloworld.ino @@ -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); +}