Try your loop like this..
void loop() {
buttonState = digitalRead(buttonPin); // Read the button, save in buttonState.
if (buttonState != HIGH) { // If its not high.. Or if its LOW (grounded)
if (currentState == 0) { // If current state = 0..
currentState++; // Bump up current state.
Serial.println(currentState); // Let the user see what we have.
} else { // Else, current state was = 1..
currentState--; // Pop one off current state.
Serial.println(currentState); // Show Mrs user what we got.
}
while (!digitalRead(buttonPin)) { // While the button is being held down..
delay(500); // Waste a 1,000 years.
if (!digitalRead(buttonPin)) { // Are they done yet?
Serial.println("Let go of the damn button!"); // Yell at the user.
}
}
}
}
-jim lee