Untitled
unknown
c_cpp
a year ago
873 B
2
Indexable
Never
int redLED = D5; int yellowLED = D6; int greenLED = D7; int speaker = D8; void setup() { // put your setup code here, to run once: pinMode(redLED, OUTPUT); pinMode(yellowLED, OUTPUT); pinMode(greenLED, OUTPUT); pinMode(speaker, OUTPUT); } void loop() { // Red light for 30 seconds digitalWrite(redLED, HIGH); digitalWrite(yellowLED, LOW); digitalWrite(greenLED, LOW); noTone(speaker); // turn off the speaker delay(30000); // 30 seconds // Yellow light for 5 seconds digitalWrite(redLED, LOW); digitalWrite(yellowLED, HIGH); digitalWrite(greenLED, LOW); noTone(speaker); // turn off the speaker delay(5000); // 5 seconds // Green light for 30 seconds digitalWrite(redLED, LOW); digitalWrite(yellowLED, LOW); digitalWrite(greenLED, HIGH); tone(speaker, 1000); // play a sound on the speaker delay(30000); // 30 seconds }