Skip to content

Instantly share code, notes, and snippets.

@ljahier
Created March 23, 2017 13:53
Show Gist options
  • Save ljahier/478388bfbadba279029c42790bb3fd86 to your computer and use it in GitHub Desktop.
Save ljahier/478388bfbadba279029c42790bb3fd86 to your computer and use it in GitHub Desktop.
int buttonState;
int buttonStateTwo;
int my_time;
void setup() {
// put your setup code here, to run once:
for (int thisPin = 2; thisPin < 5; thisPin++) {
pinMode(thisPin, OUTPUT);
}
pinMode(6, INPUT);
pinMode(7, INPUT);
pinMode(A0, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
my_time = analogRead(A0);
buttonState = digitalRead(6);
buttonStateTwo = digitalRead(7);
if (buttonState == HIGH)
{
//
for (int thisPin = 5; thisPin >= 2; thisPin--) {
// turn the pin on:
digitalWrite(thisPin, HIGH);
delay(my_time);
// turn the pin off:
digitalWrite(thisPin, LOW);
}
}
if (buttonStateTwo == HIGH)
{
for (int thisPin = 2; thisPin <= 5; thisPin++) {
// turn the pin on:
digitalWrite(thisPin, HIGH);
delay(my_time);
// turn the pin off:
digitalWrite(thisPin, LOW);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment