small changes to the Debounce example

This commit is contained in:
Fede85 2013-04-16 16:50:23 +02:00
parent 97e0f34572
commit c87ddd567d
1 changed files with 6 additions and 6 deletions

View File

@ -22,15 +22,15 @@
modified 28 Dec 2012 modified 28 Dec 2012
by Mike Walters by Mike Walters
This example code is in the public domain. This example code is in the public domain.
http://www.arduino.cc/en/Tutorial/Debounce http://www.arduino.cc/en/Tutorial/Debounce
*/ */
// constants won't change. They're used here to // constants won't change. They're used here to
// set pin numbers: // set pin numbers:
const int buttonPin = 2; // the number of the pushbutton pin const int buttonPin = 2; // the number of the pushbutton pin
const int ledPin = 13; // the number of the LED pin const int ledPin = 13; // the number of the LED pin
// Variables will change: // Variables will change:
int ledState = HIGH; // the current state of the output pin int ledState = HIGH; // the current state of the output pin
@ -75,13 +75,13 @@ void loop() {
// only toggle the LED if the new button state is HIGH // only toggle the LED if the new button state is HIGH
if (buttonState == HIGH) { if (buttonState == HIGH) {
ledState = !ledState; ledState = !ledState;
// set the LED:
digitalWrite(ledPin, ledState);
} }
} }
} }
// set the LED:
digitalWrite(ledPin, ledState);
// save the reading. Next time through the loop, // save the reading. Next time through the loop,
// it'll be the lastButtonState: // it'll be the lastButtonState:
lastButtonState = reading; lastButtonState = reading;