Push-Button Notifier
Wire up a push button and watch the web page react the instant you press it — the physical world notifying the browser.
A single characteristic holds the total number of button presses as a 32-bit counter. The app reads it once on connect (so the count survives reconnects), then subscribes to notifications for live updates.
The button pin uses the chip's internal pull-up resistor: the pin idles HIGH, and pressing the button connects it to ground, pulling it LOW. That is why the wiring needs no external resistor — just the button between pin D2 and GND.
Mechanical buttons "bounce": one press produces a burst of rapid on/off transitions for a few milliseconds. The sketch debounces by waiting for the reading to stay stable for 30 ms before accepting it as a real press. Each accepted press increments the counter and notifies the browser, which flashes and updates instantly.
Goals
- Wire a push button between D2 and GND
- Debounce presses in firmware
- Watch the browser react instantly via BLE notifications
Materials
- Arduino Nano 33 BLE (or BLE Sense)
- Push button
- Breadboard and jumper wires
- USB cable
- Arduino IDE with ArduinoBLE library