Skip to content

Instantly share code, notes, and snippets.

@mischa
Last active September 26, 2016 15:36
Show Gist options
  • Save mischa/1bb23d0c149fd323800eb116790c1ba7 to your computer and use it in GitHub Desktop.
Save mischa/1bb23d0c149fd323800eb116790c1ba7 to your computer and use it in GitHub Desktop.
const int DELAY = 100;
int LEDS[] = {11, 10, 9, 6, 5, 3};
const int LEDS_COUNT = 6;
void setup() {
Serial.begin(9600);
for(int i=0; i<LEDS_COUNT; i++) {
pinMode(LEDS[i], OUTPUT);
}
pinMode(2, INPUT);
}
int lol = 0;
void loop() {
int reading = digitalRead(2);
Serial.println(reading);
if(reading == 1) {
lol++;
} else {
lol = 0;
}
if(lol > 20) {
Serial.println("\n\n\nactivating");
for(int i=0; i<LEDS_COUNT; i++) {
int prev = i-1;
if(prev < 0) {
prev = LEDS_COUNT-1;
}
digitalWrite(LEDS[prev], LOW);
digitalWrite(LEDS[i], HIGH);
delay(100);
}
digitalWrite(LEDS[5], LOW);
lol = 0;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment