Permalink
Browse files

Added a help file and updated links

  • Loading branch information...
thomasfredericks committed Jan 10, 2018
1 parent 5a53e1b commit 3f9594d49c29350f78399599aba1e9ec6494dc60
@@ -5,7 +5,7 @@
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/Bounce-Arduino-Wiring
// https://github.com/thomasfredericks/Bounce2
#include <Bounce2.h>
#define BUTTON_PIN 2
@@ -0,0 +1,56 @@
// Detect the falling edge of multiple buttons.
// Eight buttons with internal pullups.
// Toggles a LED when any button is pressed.
// Buttons on pins 2,3,4,5,6,7,8,9
// Include the Bounce2 library found here :
// https://github.com/thomasfredericks/Bounce2
#include <Bounce2.h>
#define LED_PIN 13
#define NUM_BUTTONS 8
const uint8_t BUTTON_PINS[NUM_BUTTONS] = {2, 3, 4, 5, 6, 7, 8, 9};
int ledState = LOW;
Bounce * buttons = new Bounce[NUM_BUTTONS];
void setup() {
for (int i = 0; i < NUM_BUTTONS; i++) {
buttons[i].attach( BUTTON_PINS[i] , INPUT_PULLUP ); //setup the bounce instance for the current button
buttons[i].interval(25); // interval in ms
}
// Setup the LED :
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, ledState);
}
void loop() {
bool needToToggleLed = false;
for (int i = 0; i < NUM_BUTTONS; i++) {
// Update the Bounce instance :
buttons[i].update();
// If it fell, flag the need to toggle the LED
if ( buttons[i].fell() ) {
needToToggleLed = true;
}
}
// if a LED toggle has been flagged :
if ( needToToggleLed ) {
// Toggle LED state :
ledState = !ledState;
digitalWrite(LED_PIN, ledState);
}
}
@@ -2,7 +2,7 @@
// Detect the falling edge
// Include the Bounce2 library found here :
// https://github.com/thomasfredericks/Bounce-Arduino-Wiring
// https://github.com/thomasfredericks/Bounce2
#include <Bounce2.h>
@@ -7,7 +7,7 @@ a button press (transition from HIGH to LOW).
*/
// Include the Bounce2 library found here :
// https://github.com/thomasfredericks/Bounce-Arduino-Wiring
// https://github.com/thomasfredericks/Bounce2
#include <Bounce2.h>
@@ -9,7 +9,7 @@ Open the Serial Monitor (57600 baud) for debug messages.
*/
// Include the Bounce2 library found here :
// https://github.com/thomasfredericks/Bounce-Arduino-Wiring
// https://github.com/thomasfredericks/Bounce2
#include <Bounce2.h>

0 comments on commit 3f9594d

Please sign in to comment.