Created
March 27, 2013 03:10
-
-
Save anonymous/5251285 to your computer and use it in GitHub Desktop.
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
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 outpu | |
pinMode(BUTTON, INPUT); // and BUTTON is an input | |
} | |
void loop() { | |
val = digitalRead(BUTTON); // read input value and stor | |
// check if the input is HIGH (button pressed) | |
// and change the state | |
do { | |
if(delay_time <= 0) { | |
break; | |
} | |
delay(delay_time); | |
digitalWrite(LED, LOW); | |
delay(delay_time); | |
delay_time = delay_time - 1; | |
if(val == HIGH) { | |
digitalWrite(LED, HIGH); | |
} | |
} | |
else digitalWrite(LED, HIGH); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment