Skip to content

Instantly share code, notes, and snippets.

@yukilabo
Created January 2, 2021 06:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yukilabo/16addc16b57400bfff2704653cc7e0b1 to your computer and use it in GitHub Desktop.
Save yukilabo/16addc16b57400bfff2704653cc7e0b1 to your computer and use it in GitHub Desktop.
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