#define LED 13
#define BUTTON 7
int val = 0;
int state = 0;
void setup {
pinMode(LED, OUTPUT)
pinMode(BUTTON, INPUT)
}
void loop {
val = digitalRead(BUTTON);
if (val == HIGH && state == 0) {
digitalWrite(LED, HIGH);
pause(500);
state = 1;
}
if ((val == HIGH) && (state == 1)){
digitalWrite(LED, LOW);
pause(500);
state = 0;
}
}
No comments:
Post a Comment