Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The simplest button debounce utility for Arduino

This library is probably the simplest button debounce ulitity for Arduino. The code is based on Jack Ganssle's debounce function that he described in his part 2 of "A Guide to Debouncing" article.

Example

#include "button.h"

Button btn1;
Button btn2;

void setup() {
  btn1.begin(2);
  btn2.begin(3);
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  // press button 1 to turn on the LED
  if (btn1.debounce()) {
    digitalWrite(LED_BUILTIN, HIGH);
  }
  // press button 2 to turn off the LED
  if (btn2.debounce()) {
    digitalWrite(LED_BUILTIN, LOW);
  }
}

Refer to my blog post on the explanation on how the debounce function actually work.

About

The simplest button debounce utility for Arduino

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages