Skip to content

Commit

Permalink
worked out how to detect a click
Browse files Browse the repository at this point in the history
  • Loading branch information
d6y committed Nov 26, 2011
1 parent b407b48 commit e3e611b
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions button1/button1.pde
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void setup() {

}

int state = HIGH;
int ledState = HIGH; // i.e., Off :-(

boolean wasLow = false;

Expand All @@ -42,10 +42,11 @@ boolean click() {
void loop() {

if (click()) {
state = state == HIGH ? LOW : HIGH;
ledState = ledState == HIGH ? LOW : HIGH;
}

digitalWrite(RED, state);
digitalWrite(RED, ledState);

// if you get "bouncing" add delay(10) to "debounce"
}

0 comments on commit e3e611b

Please sign in to comment.