Skip to content

Instantly share code, notes, and snippets.

@taylorlapeyre
Forked from anonymous/gist:5251285
Last active December 15, 2015 11:09
Show Gist options
  • Save taylorlapeyre/5251297 to your computer and use it in GitHub Desktop.
Save taylorlapeyre/5251297 to your computer and use it in GitHub Desktop.
int LED = 13; // the pin for the LED
int BUTTON = 7; // the input pin where the pushbutton is connected
int val = 0; // val will be used to store the state of the input pin
int delay_time = 1000;
void setup() {
pinMode(LED, OUTPUT); // tell Arduino LED is an output
pinMode(BUTTON, INPUT); // and BUTTON is an input
}
void loop() {
while (delay_time > 0) {
val = digitalRead(BUTTON); // check if the input is HIGH (button pressed)
delay(delay_time);
digitalWrite(LED, LOW);
delay(delay_time);
// if the button is pressed..
if (val == HIGH) {
delay_time = delay_time - 1;
}
}
digitalWrite(LED, HIGH);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment