绿灯风停,红灯刮风,红绿间隙黄灯。
int Red = 13; // 红灯 int Yellow = 12; // 黄灯 int Green = 11; // 绿灯 int FanA = 8; // 风扇 VINA int FanB = 9; // 风扇 VINB void setup() { pinMode(FanA, OUTPUT); pinMode(FanB, OUTPUT); pinMode(Red, OUTPUT); pinMode(Yellow, OUTPUT); pinMode(Green, OUTPUT); } void loop() { // 绿灯亮 digitalWrite(Green, HIGH); delay(3000); // 关绿亮黄 digitalWrite(Green, LOW); digitalWrite(Yellow, HIGH); delay(1000); // 关黄亮红开风扇 digitalWrite(Yellow, LOW); digitalWrite(Red, HIGH); digitalWrite(FanA, LOW); digitalWrite(FanB, HIGH); delay(6000); // 停风扇停红亮黄 digitalWrite(FanA, LOW); digitalWrite(FanB, LOW); digitalWrite(Yellow, HIGH); digitalWrite(Red, LOW); delay(2000); // 停黄 digitalWrite(Yellow, LOW); }