Projects / Fruit touch piano

Fruit touch piano

Beginner45 minGuided buildReviewed

Build it step by step

0 of 6 done
  1. UNOMPR121

    Wire the sensor

    Connect the MPR121 on I2C and upload the sketch.

  2. UNOMPR121

    Check one key

    Touch electrode 0 with your finger and hear a note.

  3. UNOCROCOD

    Add the clips

    Clip each electrode to a different fruit.

  4. UNO

    Tune

    Change the thresholds until all keys respond but none triggers alone.

  5. UNO

    Pick the notes

    Edit NOTES to a scale you prefer.

  6. UNOMPR121

    Play a tune

    Touch the fruit in order to play a simple melody.

In short

How do you build a fruit touch piano?

An MPR121 turns bananas, apples or foil pads into piano keys that play notes when touched. You need Arduino Uno R3, MPR121 capacitive touch sensor, Passive buzzer, Crocodile clip test leads (10 pack) and Jumper wires male to male (40 pcs, 20 cm). It takes 6 steps and about 45 minutes.

Level
Beginner
Time
About 45 min
Parts
5

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
MPR121 VIN, GNDUno 5V, GNDPower (the usual breakout has a regulator; check yours)
MPR121 SDA, SCLUno A4, A5I2C
Passive buzzer +Uno D8Sound
Passive buzzer -Uno GNDReturn
MPR121 electrodes 0 to 7Crocodile clips to fruit or foil padsPiano keys
Your other hand or a clip to GNDMPR121 GND is not requiredThe body provides the capacitance path

Code

Arduino IDE, board "Arduino Uno". Install "Adafruit MPR121". Use whole, clean fruit or foil-covered card pads as electrodes and wash hands afterwards; do not eat food that the clips have touched. Hold the fruit or touch with a bare finger: the sensor reads how much your body adds to the capacitance. Raise the thresholds for big, wet objects and lower them for small foil pads.

Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).

#include <Wire.h>
#include <Adafruit_MPR121.h>

Adafruit_MPR121 cap = Adafruit_MPR121();
const int NOTES[8] = { 262, 294, 330, 349, 392, 440, 494, 523 };   // C4 up to C5
const byte BUZZER = 8;

void setup() {
  Serial.begin(9600);
  if (!cap.begin(0x5A)) { Serial.println("MPR121 not found"); while (true); }
  cap.setThresholds(12, 6);                 // touch and release thresholds; raise for large objects
}

void loop() {
  uint16_t touched = cap.touched();
  int note = 0;
  for (byte i = 0; i < 8; i++) if (touched & (1 << i)) note = NOTES[i];       // the highest touched key wins
  if (note) tone(BUZZER, note); else noTone(BUZZER);
  delay(10);
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Nothing touchedSilent
Touch a fruitIts note plays
Two fruits at onceThe higher note plays
ReleaseSound stops

If it does not work

MPR121 not found

Check I2C wiring and its supply voltage.

Keys trigger by themselves

Raise the touch threshold or move the clips apart.

Some keys do not react

Lower the thresholds or touch more firmly.

Notes are scratchy

A passive buzzer is harsh. Try a small speaker with a 100 Ω resistor.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the fruit touch piano?

Arduino Uno R3, MPR121 capacitive touch sensor, Passive buzzer, Crocodile clip test leads (10 pack) and Jumper wires male to male (40 pcs, 20 cm).

How long does the fruit touch piano take to build?

About 45 minutes for a beginner maker, in 6 steps.

How do I know the fruit touch piano works?

Nothing touched: Silent. Touch a fruit: Its note plays. Two fruits at once: The higher note plays.

MPR121 not found: what should I check?

Check I2C wiring and its supply voltage.

Keys trigger by themselves: what should I check?

Raise the touch threshold or move the clips apart.

Some keys do not react: what should I check?

Lower the thresholds or touch more firmly.

Notes are scratchy: what should I check?

A passive buzzer is harsh. Try a small speaker with a 100 Ω resistor.