Created
July 28, 2016 09:02
-
-
Save jjsanderson/9102a33dbc3b8eadcd23511964849c93 to your computer and use it in GitHub Desktop.
Traffic Light code for Arduino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See the main TrafficLights project for full code.