Last active
May 21, 2019 09:54
-
-
Save ghostoy/23c5675c1f7cb5fb7608dda9d03489b6 to your computer and use it in GitHub Desktop.
Arduino控制3个LED循环亮灭
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const int redPin = 13; | |
const int yellowPin = 12; | |
const int bluePin = 11; | |
void setup() { | |
pinMode(redPin, OUTPUT); // 设置3个LED的端口为输出 | |
pinMode(yellowPin, OUTPUT); | |
pinMode(bluePin, OUTPUT); | |
} | |
void loop() { | |
digitalWrite(redPin, HIGH); // 点亮红灯 | |
delay(1000); | |
digitalWrite(redPin, LOW); // 熄灭红灯 | |
digitalWrite(yellowPin, HIGH); // 点亮黄灯 | |
delay(1000); | |
digitalWrite(yellowPin, LOW); // 熄灭黄灯 | |
digitalWrite(bluePin, HIGH); // 点亮蓝灯 | |
delay(1000); | |
digitalWrite(bluePin, LOW); // 熄灭蓝灯 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment