Skip to content

Instantly share code, notes, and snippets.

@fjukstad
Created October 18, 2015 11: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 fjukstad/718203f2f292c4b90106 to your computer and use it in GitHub Desktop.
Save fjukstad/718203f2f292c4b90106 to your computer and use it in GitHub Desktop.
Simple spaceship interface. Project # 2 from the Arduino starterkit.
int switchState = 0;
void setup() {
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(2, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
switchState = digitalRead(2);
if(switchState == LOW){
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
} else {
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
delay(250);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
delay(250);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment