Initial commit
This is just the 2018 code configured for PlatformIO
This commit is contained in:
48
lib/Bounce2/examples/bounce/bounce.ino
Normal file
48
lib/Bounce2/examples/bounce/bounce.ino
Normal file
@ -0,0 +1,48 @@
|
||||
|
||||
/*
|
||||
DESCRIPTION
|
||||
====================
|
||||
Simple example of the Bounce library that switches the debug LED when a button is pressed.
|
||||
*/
|
||||
// Include the Bounce2 library found here :
|
||||
// https://github.com/thomasfredericks/Bounce2
|
||||
#include <Bounce2.h>
|
||||
|
||||
#define BUTTON_PIN 2
|
||||
#define LED_PIN 13
|
||||
|
||||
// Instantiate a Bounce object
|
||||
Bounce debouncer = Bounce();
|
||||
|
||||
void setup() {
|
||||
|
||||
// Setup the button with an internal pull-up :
|
||||
pinMode(BUTTON_PIN,INPUT_PULLUP);
|
||||
|
||||
// After setting up the button, setup the Bounce instance :
|
||||
debouncer.attach(BUTTON_PIN);
|
||||
debouncer.interval(5); // interval in ms
|
||||
|
||||
//Setup the LED :
|
||||
pinMode(LED_PIN,OUTPUT);
|
||||
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// Update the Bounce instance :
|
||||
debouncer.update();
|
||||
|
||||
// Get the updated value :
|
||||
int value = debouncer.read();
|
||||
|
||||
// Turn on or off the LED as determined by the state :
|
||||
if ( value == LOW ) {
|
||||
digitalWrite(LED_PIN, HIGH );
|
||||
}
|
||||
else {
|
||||
digitalWrite(LED_PIN, LOW );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user