Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
traffic_signal
#define PIN_GREEN 0
#define PIN_YELLOW 4
#define PIN_RED 2
#define PIN_GND 1
void setup() {
// put your setup code here, to run once:
pinMode(PIN_GREEN, OUTPUT);
pinMode(PIN_GND, OUTPUT);
pinMode(PIN_YELLOW, OUTPUT);
pinMode(PIN_RED, OUTPUT);
analogWrite(PIN_GND, 100);
digitalWrite(PIN_YELLOW, LOW);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(PIN_RED, LOW);
digitalWrite(PIN_GREEN, HIGH);
delay(20000);
digitalWrite(PIN_GREEN, LOW);
digitalWrite(PIN_YELLOW, HIGH);
delay(3000);
digitalWrite(PIN_YELLOW, LOW);
digitalWrite(PIN_RED, HIGH);
delay(15000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment