06 / 20
Build a mini piano
Eight copper pads use capacitive touch to play an octave.
Run this experiment →Why it’s here
Hold the on-screen copper keys and compare the displayed note frequencies.
How it works
Eight copper pads use capacitive touch to play an octave. No. This course targets the original ESP32 touch peripheral. Check your exact chip and calibrate untouched values. This guided model targets the original ESP32 and Arduino-ESP32 3.x; radio, acoustics, loads and mechanics are simplified.
Try it
- Open this experiment
- Hold the on-screen copper keys and compare the displayed note frequencies.
Connections
- 4,13,14,27,32,33,15,12 — Eight touch pads C4–C5; avoid strap interference at boot
- GPIO 25 / GND — Passive buzzer
Example sketch
const int pads[] = {4, 13, 14, 27, 32, 33, 15, 12};
const int notes[] = {262, 294, 330, 349, 392, 440, 494, 523};
// Original ESP32 only. Calibrate touch threshold; GPIO12/15 are boot straps.
void setup() {
ledcAttach(25, 1000, 8);
}
void loop() {
int note = 0;
for (int i = 0; i < 8; i++) {
if (touchRead(pads[i]) < 30) { note = notes[i]; break; }
}
ledcWriteTone(25, note);
delay(10);
}Check your understanding
Is touchRead available on every ESP32 variant?
Show the answer
No. This course targets the original ESP32 touch peripheral. Check your exact chip and calibrate untouched values.