Robotics/electronics

Capacitive-Touch Cardboard Piano

Turn foil-covered cardboard keys into capacitive touch inputs that play a simple five-note scale.

Touching a foil pad changes how quickly a tiny electrical charge moves. The controller measures that change and maps each key to a note without a mechanical switch.

Difficulty
Intermediate
Build time
75-120 min
Estimated cost
$0-$20
Age range
12-17
Workspace
A clear table about 90 cm wide

The finish line

What you will build

Five labeled keys each trigger the correct note in nine of ten presses without neighboring false triggers.

Learning goals

  • Identify how finger contact changing key capacitance produces five mapped audio notes.
  • Construct and explain a touch event-to-digital sound output system.
  • Measure how key spacing or threshold changes performance.
  • Diagnose losses caused by electrical noise and key coupling.

Before you build

Materials, tools, and safety

Reuse-material cost: Usually under $5 with an existing kit. Supervision: Adult guidance recommended for wiring and cutting.

Tools

  • Small screwdriver
  • Wire stripper
  • Multimeter
  • Low-temperature glue gun or tape

Low-cost swaps

  • Use alligator-clip leads for a no-solder version.
  • Build and test the mechanism manually before adding electronics.
  • Use a classroom board with built-in capacitive pads and attach larger foil keys by alligator leads.

Wiring table

FromToPurpose
Five foil keysFive supported touch inputs through required resistorsMeasure individual touch events
Piezo positiveTone-capable pin 9Generate note frequencies
Piezo negativeGNDComplete audio circuit
USBControllerSupply isolated low-voltage power

Project-specific safety

  • Use only the listed low-voltage battery supply; never use mains electricity.
  • Disconnect power before changing wires and stop if a motor, wire, or battery becomes warm.
  • Use USB or battery low voltage only, smooth and tape foil edges, and never connect touch pads to outlets or unknown equipment.

Orient the build

Place the build so finger contact changing key capacitance is on your left and five mapped audio notes is on your right. Call the side facing you the front, the far side the back, the tabletop the bottom, and the opposite face the top.

Build it

Step-by-step instructions

  1. Step 1

    Build five keys

    Wrap identical card rectangles with smooth foil and tape every edge.

    Leave a rear connection tab.

  2. Step 2

    Space the keyboard

    Mount keys with at least 1 cm gaps on a nonconductive base.

    Label C through G.

  3. Step 3

    Connect touch channels

    Wire each tab to a separate supported sensing pin with required resistor arrangement.

    Keep leads separated.

    Builder checkpoint: After connect touch channels, the first subassembly should stay aligned when handled gently.

  4. Step 4

    Add the speaker

    Connect a passive piezo to the chosen tone pin and ground.

    Keep volume comfortable.

    Watch for: If this stage binds or drifts, inspect ground variation before adding more parts.

  5. Step 5

    Read baselines

    Log every key untouched for ten seconds and record normal ranges.

    Avoid touching the desk during this step.

  6. Step 6

    Set per-key thresholds

    Touch each key ten times and choose a threshold between baseline and touch values.

    Do not assume all keys match.

    Builder checkpoint: After set per-key thresholds, operate the build slowly and confirm that five mapped audio notes begins without binding.

  7. Step 7

    Map notes

    Assign C4, D4, E4, F4, and G4 frequencies.

    Play only the highest-confidence active key.

  8. Step 8

    Run isolation trials

    Press each key ten times and record correct, missed, and neighboring triggers.

    Increase spacing or tune thresholds.

    Builder checkpoint: At the final checkpoint, Five labeled keys each trigger the correct note in nine of ten presses without neighboring false triggers.

See the engineering

Why it works

Input
finger contact changing key capacitance
Output
five mapped audio notes
Motion
touch event-to-digital sound output
Energy losses
electrical noise, key coupling, loose foil, ground variation
Capacitive-Touch Cardboard Piano concept diagram with labeled input, output, and motion arrows.
The touch event-to-digital sound output motion path, with the main efficiency losses called out.

Why this works

Capacitive touch sensing

A conductive pad and the surrounding environment form a small capacitor. Touch adds body capacitance, changing measured charge time or sensor value enough to cross a calibrated threshold.

Look for: Log baseline and touched readings for each key before enabling sound.

Where the energy goes

Efficiency and losses

The ideal model leaves out electrical noise, key coupling, loose foil, ground variation. These effects turn some input energy into heat, sound, vibration, or unwanted motion, so measured performance will be lower than an ideal calculation.

Look for: Run the build slowly and locate the first place where electrical noise becomes visible or audible.

Math bite

Calculate key reliability

Formula: reliability = correct triggers / presses × 100%

  • Correct triggers = 9
  • Presses = 10

Substitute: reliability = 9 / 10 × 100% = 90%

Result: This key triggers correctly 90 percent of the time.

Each key needs its own result.

Humidity and grounding can change sensitivity.

touch_piano.ino

A complete example for boards whose supported touchRead function returns larger values when touched; calibrate pins and thresholds for your board.

const int keys[5]={4,5,6,7,8};
const int notes[5]={262,294,330,349,392};
const int thresholds[5]={35,35,35,35,35}; const int buzzer=9;
void setup(){ pinMode(buzzer,OUTPUT); }
void loop(){
  int active=-1, strongest=0;
  for(int i=0;i<5;i++){
    int value=touchRead(keys[i]);
    if(value>thresholds[i] && value>strongest){ strongest=value; active=i; }
  }
  if(active>=0) tone(buzzer,notes[active]); else noTone(buzzer);
  delay(15);
}
Brick-building meme reading: Chuck Norris does not build LEGO; he roundhouses the bricks into sculptures.
The cardboard piano played C, D, E, and one note caused by a very enthusiastic sleeve.Image supplied by the site owner.

Make it behave

Test, troubleshoot, and tune

Controlled test

Start here: Log untouched and touched values before connecting the buzzer logic.

Success looks like: Every key produces its mapped note in nine of ten presses with no adjacent false trigger.

Measure: Correct notes, misses, false triggers, baseline, and touch values.

Change: key spacing or threshold

Keep constant: controller, wiring, operator, room, key size, and sample count

  1. 0.5 cm gaps
  2. 1 cm gaps
  3. 2 cm gaps
Troubleshooting guide
SymptomLikely causeConfirm itFix
Keys trigger untouchedThreshold is too low or wires coupleLog baseline with hands awayRaise threshold and separate leads
Touches are missedFoil connection or threshold is poorMeasure the raw touched rangeResecure foil and lower threshold carefully
Two notes playKeys are too close or code accepts multiple channelsTouch one center and inspect readingsIncrease spacing and choose one active key
Tone is wrongFrequency mapping or pin differsPrint detected key labelCorrect the note table

Choose your tradeoff

Calibrate each key in the actual room before changing sound code. More sensitivity helps light touches but increases false triggers from nearby hands and wiring.

Keep experimenting

Try another version

Easier

Three-note keyboard

Use three large keys.

Performance

Dynamic duration

Hold the note while touch remains stable.

Advanced

Chord mode

Detect separated simultaneous keys and manage priority safely.

Build together

Classroom and access options

Classroom version

Teams can compare key spacing or threshold while keeping controller, wiring, operator, room, key size, and sample count. Assign builder, tester, recorder, and explainer roles; have each team predict the result before collecting three trials.

Access adaptations

  • Color-code and label every wire at both ends.
  • Use clip leads, larger controls, and pre-crimped connectors when fine motor work is difficult.
  • Make keys 10 cm wide with raised note labels and provide an alternate button keyboard.

Reflect on the design

  1. How did key spacing or threshold change the measured result?
  2. Where did electrical noise affect the build most strongly?
  3. What evidence shows that capacitive touch sensing explains the motion?
  4. Which change would improve five mapped audio notes without creating a new problem?
Glossary
Capacitive touch sensing
A conductive pad and the surrounding environment form a small capacitor.
Input
The action or energy supplied to a system; here it is finger contact changing key capacitance.
Output
The useful response produced by a system; here it is five mapped audio notes.
Efficiency
The fraction of input energy that becomes useful output instead of friction, sound, heat, or unwanted motion.

Build your dreams

One build can start the next.

Share what you learned, change one variable, and help another builder understand what worked.

Explore more guides

Sources and build notes

A platform-agnostic low-voltage robotics or electronics project with original assembly guidance.

  • Low-voltage design review: Battery voltage, polarity, component roles, current paths, and motor or LED protection were editorially checked.

Written and edited by BrickLabClips. Published 2026-07-22; updated 2026-07-22.

Next builds

Related guides