Menu

ESP32: one button, two jobs — tap rings, hold 1s resets (millis)

#esp32#redditesp32#button#piezo#hardware
Reading 0:00
15s threshold

Same Wi-Fi doorbell hardware as before: one tactile button, one piezo, a page on any browser on the LAN.

New idea: time how long a clean (debounced) press lasts with millis(). Let go before 1 second = tap (ring). Still holding at 1 second = hold (reset count to 0).

Hardware

- ESP32 DevKit (30-pin)

- 6 mm tactile push button

- Passive piezo buzzer

- 4 jumpers + breadboard

Wiring

- GPIO33 → button → GND (INPUT_PULLUP)

- GPIO25 → piezo → GND

How it works

  1. Debounce as usual (50 ms quiet window)

  2. On clean press, start a stopwatch

  3. Release before 1 s → tap / ding / ring++

  4. Still down at 1 s → hold fires immediately, count resets

Happy to share the sketch if useful. Short walkthrough: https://www.youtube.com/shorts/bzs_N4e8Wxw

submitted by /u/ToneAny3403
[link] [comments]