Debouncing a button is a common issue for the effective operation of a button. The physical imperfections of the button lead to voltage bounces when the button is pressed, resulting in a voltage signal that bounces just like the following figure:

Voltage Bouncing

I tackled this issue with Arduino some time ago (pomodoro timer with arduino (ita)), but recently I’ve started experimenting a bit with the ESP32 board and revisited the problem using this framework and programming language C++.

To get started with this board and become familiar with the APIs provided by the framework (esp-idf), I implemented a simple firmware that reads the state change of a button, turning a LED on and off.

Requirements

  • esp-idf framework installed (Get started with esp32, I use VsCode with esp-idf extension)
  • esp32 with usb cable
  • Breadboard and some wires
  • Led
  • Resistor 220\(\Omega\)
  • Button

Schematics

Schematics

Firmware Development

You can find my code in my repository, in the folder debouncing_button. Debouncing Button project