Arduino Nano ESP32 - Button LED
This tutorial guides you through utilizing the Arduino Nano ESP32 and a button to control the LED. We will explore two distinct use-cases:
Use-Case 1 - Synchronization between the LED and button states, explained as follows:
- The Arduino Nano ESP32 activates the LED when the button is pressed.
- The Arduino Nano ESP32 deactivates the LED when the button is not pressed.
Use-Case 2 - Toggling the LED state with each button press, detailed as follows:
- If the Arduino Nano ESP32 detects a transition from a HIGH to a LOW state in the button (indicating a press), it toggles the LED ON if it's currently OFF, or OFF if it's currently ON.
- Releasing the button has no impact on the LED state.
In Use-Case 2, it is crucial to debounce the button to ensure proper functionality. We will explore the significance of debouncing by comparing the LED behavior when using the Arduino Nano ESP32 code with and without button debouncing.
Or you can buy the following sensor kit:
|DIYables Sensor Kit 30 types, 69 units
This image is created using Fritzing. Click to enlarge image