Table of Contents

FruitPiano

Introduction

FruitPiano is an interactive project that turns 8 fruits into piano keys — each one triggering a specific musical note. When a fruit is touched, the system plays the corresponding sound and displays the note on an LCD screen. An additional feature is a recording mode, allowing users to save and replay up to five custom melodies.

The project aims to create an unconventional, educational, and engaging musical instrument by applying key concepts learned in microcontroller laboratories. It combines capacitive touch detection with real-time audio, visual, and textual feedback to deliver a rich user experience.

FruitPiano stands out by blending play and learning — making it ideal for tech demos, creative presentations, or hands-on STEM education.

General Description

Hardware Modules

Arduino Uno - Main control unit. It receives input from all sensors (capacitive touch, push button) and drives all outputs (buzzer, LEDs, LCD display).

Fruits (Capacitive Sensors) - Each fruit acts as an individual capacitive touch sensor. Touching a fruit changes the capacitance, which is detected via dedicated sensing pins.

Buzzer - A passive buzzer is used to produce musical tones. Each fruit corresponds to a unique frequency played using PWM.

16×2 LCD Display (I2C) – Provides textual feedback by displaying the current note or system state (e.g., recording, playback). It uses the I²C interface to save digital pins.

Record Button – Toggles recording mode on/off. When active, all notes and pauses are stored sequentially into memory.

Playback Button – Allows the user to sequentially replay previously recorded melodies (up to five), navigating through them one by one.

Record Indicator LED – Lights up to show when the system is in recording mode. Turns off when exiting record mode or after automatic save.

Interaction Flow

1. The user touches a fruit

 → Capacitive sensor detects input  
 → Arduino identifies which fruit was touched  
 → Plays corresponding tone on buzzer  
 → Displays note name on the LCD

2. If recording mode is active (LED ON):

 → Each touched note is stored with its duration  
 → Any pause (time between touches) is also measured and saved  
 → Recording stops when the user presses the record button again  
    OR when the maximum number of notes is reached (auto-save)

3. When the playback button is pressed (and recording is OFF):

 → The system plays the most recent saved melody  
 → Notes and pauses are reproduced with original timing  
 → Each press plays the previous melody (up to 5 stored)  
 → If more than 5 recordings are made, the oldest is overwritten

4. The LED indicator:

 → ON when recording is active  
 → OFF when not recording

Block Diagram

Diagramă Arduino UNO - Fruit Piano

Hardware Design

Components Scheme

All pin mappings were chosen to minimize interference, keep I²C free for the display, and allow PWM output for the buzzer. The capacitive sensing uses a shared send pin (D2) and 6 receive pins (D3–D10), each connected via a 1MΩ resistor to the respective fruit. Digital pins A0 and A1 are used for control buttons with internal pull-up configuration. A digital output pin (D12) is used to control an LED as a visual indicator during the recording state.

Components Diagram - Fruit Piano

Pin Configuration

Component Arduino Uno Pin(s) Type Description
Capacitive Input (Fruits) D3 – D10 Digital Input One input pin per fruit (8 total) for detecting touch events
Capacitive Send Pin D2 Digital Output Common send pin used by all capacitive sensors
Buzzer D11 PWM Output Plays audio tones
LCD Display (I2C) A4 (SDA), A5 (SCL) I2C Interface Displays note names and system status
Record Button A1 Digital Input Toggles recording mode on/off (using INPUT_PULLUP)
Playback Button A0 Digital Input Cycles through saved melodies and triggers playback
Recording LED D12 Digital Output Turns on during active recording session

Additional Notes

- Pins A4 and A5 are reserved for the I²C bus and used exclusively by the LCD display.

- D11 was chosen for the buzzer since it supports PWM, but any other PWM-capable digital pin could be used.

- D2 is used as the common send pin for all capacitive sensors; it must remain stable during sensing.

- Buttons are wired using INPUT_PULLUP mode, eliminating the need for external pull-down resistors.

- The system supports up to 5 saved melodies in memory; a recording LED provides visual status.

Bill of Materials (BOM)

Component Description Quantity
Arduino Uno Microcontroller board 1
Passive Buzzer Used for sound output (PWM controlled) 1
LCD 16x2 with I2C Display module with I2C backpack 1
Fruits Capacitive touch input elements 8
Resistors 1MΩ (sensors), 10kΩ (buttons), 220Ω (LED) 10+
Breadboard Solderless prototyping board 1
Jumper Wires Male-male / Male-female as needed ~30
LED Indicates recording mode 1
Push Button (x2) Toggle record / playback 2

Software Design

External Libraries Used

Code Components

The code is divided into three major components:

Game Flow / Usage Flow

Implementation Details

Optimizations

Used Labs / Theoretical Foundations

Results

Github repository

YouTube - demo FruitPiano

 Full HW

 Start image  Touching a key  Recording

Conclusion

I’m proud to say I’ve met every requirement—from demonstrating concepts in at least three labs (GPIO, USART, PWM, I²C) to delivering a fully functional Fruit Piano with recording and playback. The project works smoothly, and the process has been a delightful learning experience in sensor calibration. As a bonus, my “hardware” happens to be the most changeable of them all—bananas are wonderfully perishable, so this is about as far from rigid hardware as you can get!

Bibliography

Arduino Official Documentation
Capacitive Sensor by Paul Stoffregen
LiquidCrystal-I2C