// 定义引脚 const int redPin = 9; // 红色 LED 连接到 Pin 9 const int greenPin = 10; // 绿色 LED 连接到 Pin 10 void setup() { // 初始化引脚模式 pinMode(redPin, OUTPUT); // 设置红色引脚为输出模式 pinMode(greenPin, OUTPUT); // 设置绿色引脚为输出模式 } void loop() { // 红色 LED 开,绿色 LED 关 digitalWrite(redPin, HIGH); // 红色 LED 点亮 digitalWrite(greenPin, LOW); // 绿色 LED 熄灭 delay(1000); // 等待 1 秒 // 绿色 LED 开,红色 LED 关 digitalWrite(redPin, LOW); // 红色 LED 熄灭 digitalWrite(greenPin, HIGH); // 绿色 LED 点亮 delay(1000); // 等待 1 秒 }