/* debounceNoDebounce 2 buttons without debounce This script shows the impact of button bounce in different situations. */ //Global variables //set up pins 8 & 9 with buttons const int buttonPin1 = 8; const int buttonPin2 = 9; //built in led const int ledPin = 13; void setup() { Serial.begin(9600); Serial.println("debounceNoDebounce"); pinMode(buttonPin1, INPUT); pinMode(buttonPin2, INPUT); pinMode(ledPin, OUTPUT); } void loop() { //local variable int Pressed; Pressed = digitalRead(buttonPin1); //With an LED being turned on or off, if the button bounces the same signal to turn it on is repeated //However to the user there are no implications if (Pressed > 0) {//Code to do something when button 1 pressed goes in here digitalWrite(ledPin,HIGH); }else{ digitalWrite(ledPin,LOW); } Pressed = digitalRead(buttonPin2); //With button 2 we see the impact in multiple Serial.println() taking place if (Pressed > 0) {//Code to do something when button 2 pressed goes in here Serial.println("Button 2 Pressed"); Serial.println(millis()); } }