Project Goal
Wire up several capacitive touch pads next to a buzzer and build a genuinely playable touch-sensitive keyboard, no mechanical switches anywhere, just a fingertip on a pad and an instant note, the same sensing technology behind a modern light switch or a phone's home button.
What the Controller Does
It continuously checks each touch module's output, and the moment one goes high, plays that pad's assigned note on the buzzer, for as long as the touch is held or as a short fixed beep, either approach works.
What the Touch Sensors Do
Each module detects the tiny change in electrical capacitance caused by a fingertip touching its pad and reports it as a simple digital HIGH or LOW, no pressure or mechanical actuation required at all, just proximity of a conductive touch.
What the Buzzer Does
It plays whichever frequency the controller assigns to the pad currently being touched, giving each key its own distinct musical note.
Software and Library Concepts
Get one touch pad reliably triggering one fixed tone first, then scale that same pattern up to as many pads as you have available GPIO pins for, assigning each its own note in a simple musical scale.
Testing and Troubleshooting
- A pad triggers on its own with nothing touching it, most modules have an onboard sensitivity trimmer, and keeping wiring away from other pads reduces stray capacitive coupling between them.
- A pad doesn't register a genuine touch, some modules default to toggle mode instead of momentary mode, check the module's mode-select solder pad or jumper if present.
- Two notes play at once unexpectedly, add simple debounce logic so a single touch reads as one clean event rather than several rapid triggers.
Optional Upgrade
Add the OLED display from the parts bin to show which note is currently being played, turning it into a small visual instrument as well as an audible one.
Wiring
- TTP223 VCC → ESP32-C3 SuperMini 3V3
- TTP223 GND → ESP32-C3 SuperMini GND
- TTP223 OUT → ESP32-C3 SuperMini GPIO4 — general-purpose pin; avoid GPIO2/8/9 which are boot-strapping pins on many ESP32-C3 boards
- Active Buzzer VCC/signal → ESP32-C3 SuperMini GPIO5
- Active Buzzer GND → ESP32-C3 SuperMini GND
Exact GPIO numbering/labeling can vary slightly between different "ESP32-C3 SuperMini" board vendors — the `#define`s below are set to commonly-safe general-purpose pins, but check your board's silkscreen and adjust if those pins are used for something else on your specific board.
Scope honesty: the parts list contains one TTP223 touch pad and one active buzzer, so this is genuinely a single-pad "note trigger" demo, not a multi-key piano — there's nothing in the parts list to fabricate additional keys from. The code is written as a clean, reusable building block: a debounced touch-to-sound trigger. To turn this into an actual multi-key piano, add more TTP223 modules (one per key) on additional free GPIOs and replicate the same read/trigger pattern per pin — that's the real, honest path to scaling this up.
Also being honest about the buzzer: an "active" buzzer module has its own internal oscillator and only clicks/beeps at one fixed pitch when driven HIGH — it cannot play distinct musical notes/pitches the way a passive piezo driven with `tone()`/`ledcWriteTone()` PWM can. So the code below does not fake pitch-bending; instead it produces rhythmic on/off patterns (short tap = short beep, held touch = sustained beep) as the honest capability of this part. If real musical notes are wanted later, swap in a passive buzzer/piezo.
TTP223 modules are usually active-HIGH out of the box (OUT goes HIGH on touch), but some boards have a solder-jumper to invert this to active-LOW — verify against your module before wiring logic that assumes HIGH-on-touch.