mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-17 06:52:18 +01:00
small changes to the Debounce example
This commit is contained in:
parent
97e0f34572
commit
c87ddd567d
@ -22,15 +22,15 @@
|
||||
modified 28 Dec 2012
|
||||
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
|
||||
*/
|
||||
|
||||
// constants won't change. They're used here to
|
||||
// set pin numbers:
|
||||
const int buttonPin = 2; // the number of the pushbutton pin
|
||||
const int ledPin = 13; // the number of the LED pin
|
||||
const int buttonPin = 2; // the number of the pushbutton pin
|
||||
const int ledPin = 13; // the number of the LED pin
|
||||
|
||||
// Variables will change:
|
||||
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
|
||||
if (buttonState == HIGH) {
|
||||
ledState = !ledState;
|
||||
|
||||
// set the LED:
|
||||
digitalWrite(ledPin, ledState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// set the LED:
|
||||
digitalWrite(ledPin, ledState);
|
||||
|
||||
// save the reading. Next time through the loop,
|
||||
// it'll be the lastButtonState:
|
||||
lastButtonState = reading;
|
||||
|
Loading…
x
Reference in New Issue
Block a user