Skip to content

Instantly share code, notes, and snippets.

@jjsanderson
Created July 28, 2016 09:02
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 jjsanderson/9102a33dbc3b8eadcd23511964849c93 to your computer and use it in GitHub Desktop.
Save jjsanderson/9102a33dbc3b8eadcd23511964849c93 to your computer and use it in GitHub Desktop.
Traffic Light code for Arduino
#define RED 9
#define AMBER 10
#define GREEN 11
void setup() {
pinMode(RED, OUTPUT);
pinMode(AMBER, OUTPUT);
pinMode(GREEN, OUTPUT);
}
// the loop function runs over and over again forever
void loop() {
digitalWrite(RED, HIGH); // turn the RED LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(RED, LOW); // turn the RED LED off by making the voltage LOW
digitalWrite(AMBER, HIGH);
delay(1000);
digitalWrite(AMBER, LOW);
digitalWrite(GREEN, HIGH);
delay(1000);
digitalWrite(GREEN, LOW);
}
@jjsanderson
Copy link
Author

See the main TrafficLights project for full code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment