กลับไปหน้ารวมไฟล์
diy-piano-make-piano-with-touch-based-keys-touch-sensor-248fbf-en.md

Keyless Musical Instrument Innovation: Building a Touch Piano with Arduino and Capacitive Sensing

This project transforms the traditional concept of musical instruments from using mechanical keys to utilizing touch sensors. It leverages the principles of electrostatics and changes in capacitance to create melodies with just a touch of a finger.

Demonstration Video of the DIY Keyless piano with arduino

What is your project about?

This project is about making a piano from scratch. It does not have keys instead it has touch sensors. So, no need to press it just touch it. After touching it a tone is generated, and at last, we can combine different tones to form a melody.

Why did you decide to make it?

I have no experience with any music or musical instrument. So, I created one for myself. I would have interfaced different buttons with the Arduino UNO and speaker but that would be boring. To make it interesting, I added touch sensors instead of switches/buttons.

How does it work?

The core of this project is the use of the <CapacitiveSensor.h> library, which can turn Arduino's Digital I/O pins into touch detection sensors.

#include <CapacitiveSensor.h>

RC Time Constant Theory: This mechanism relies on a basic RC (Resistor-Capacitor) circuit. The sensor consists of a high-resistance resistor (10k - 10M Ohm) connected to an aluminum foil sheet acting as an electrode.

  1. Arduino sends a pulse signal (Send Pin) through the resistor to the foil sheet.
  2. The signal is received back at the Receive Pin.
  3. The system calculates the "Time Constant" or the time it takes to fully charge the capacitor.

When a human body (which has inherent capacitance) approaches or touches the foil sheet, the total capacitance of the system changes according to the formula $T = R \times C$. As $C$ increases, the time $T$ taken to receive the signal also lengthens. Arduino detects this change in microseconds and interprets it as a "touch".

Aluminium Foil acting as touch sensor

Circuit Schematic

The circuit design emphasizes simplicity yet high efficiency, with Arduino Uno serving as the central microcontroller for processing signals from all 7 touch points.

Circuit schematic for arduino piano with touch sensor based keys and speaker

In this circuit, we use 10k Ohm resistors connected across the send and receive pins for touch sensing. Additionally, an NPN Transistor acts as an electronic switch to drive current to the speaker. Since Arduino's I/O pins have limited current, using a transistor helps the speaker operate at full efficiency and produce clearer sound.

Components & Connections

Arduino Uno

Arduino Uno R3
The Arduino Uno prototyping board is the main component and brain of the project.

Breadboard

Breadboard
Used for prototyping circuits, allowing connections to be changed without soldering.

Resistors

10 Kilo Ohm Resistor
Then we have 7, 10-kilo ohm resistors. we will connect them as per the schematic.

Transistor

NPN Transistor
This is an N-P-N transistor, it will be used for switching the speaker.

Speaker

And, Here is the speaker, it will be used to play the tones.

Alligator Clips

Alligator Clip
And alligator clips to make connections with foil strips.

Aluminium Foil Strip

Auluminium Foil Strips attach to cardboard
This is the main component of this project. It has a few aluminum strips glued to a cardboard strip. It will act as a touch sensor.

Musical Notes

In terms of software, we have defined frequencies in Hertz (Hz) to correspond with basic musical notes, allowing this instrument to play actual songs. These are stored in an Array format as follows:

Note Frequency (Hz)
Sa (Do) 240
Re 270
Ga (Mi) 300
Ma (Fa) 320
Pa (Sol) 360
Dha (La) 400
Ni (Si) 450
int freq[] = {240,270,300,320,360,400,450,480};

Issues

  • White Noise: When we were not playing any tune, the speaker generated a lot of white noise. This is caused by electrical noise and floating input values and can be resolved by adding digital filtering in the code.
  • Inconsistent Volume: The volume of sound was not constant, due to loose connections. This issue often arises from loose connections on the breadboard or alligator clips, which affect the total resistance of the circuit.
  • Playing Skill: Playing this happy birthday tune required a lot of practice, as we don't have any background experience in music. Playing songs with precise timing on a touch-based system requires practice, as the sensor response time may differ slightly from normal push buttons.

Applications

This circuit can be used as a touch sensor. The Capacitive Touch technology from this project can be extended to various applications:

  • Security System: It can be attached to the knob or handle of the door to detect the touch of the burglar. Then trigger the alarm.
  • Portable Musical Instrument: Also, it can be used to make a paper-thin piano, which will have the thickness of cardboard. It won't have any keys to be pressed. but touch sensors. Also, it can be foldable so as to carry it anywhere.
  • Flexible Keyboard: A flexible computer keyboard can be made out of it.

Conclusion

This project serves as an excellent starting point for learning about sensor operation and digital signal processing. While the resulting instrument might be a hybrid between a piano and a harmonium, the most important aspects are the joy of building a musical instrument from everyday materials and the inspiration to extend embedded engineering to other creations.

Full demonstration Video

This was a very interesting project; we learned a lot while making it. We don't even know whether it is a piano or a harmonium. But we enjoyed it a lot playing tunes on it.

ข้อมูล Frontmatter ดั้งเดิม

apps:
  - "1x Arduino IDE"
author: "RoboticsEveryDay"
category: ""
components:
  - "1x Speaker: 0.25W, 8 ohms"
  - "1x 9V 1A Switching Wall Power Supply"
  - "1x Tape, Clear"
  - "1x Arduino UNO"
  - "1x Wire Cutter / Stripper, 5.25 \" Overall Length"
  - "1x General Purpose Transistor NPN"
  - "1x Test Cable Assembly, Alligator Terminated Test Lead Set"
  - "1x Breadboard (generic)"
  - "1x Jumper wires (generic)"
  - "1x Multitool, Screwdriver"
  - "1x Resistor 10k ohm"
  - "1x Scissor, Electrician"
  - "1x Conductive Tape, Copper Foil"
description: "This is an Arduino-based Piano. It has capacitive touch sensors instead of keys. No need to press it just touch it and play tunes on speaker"
difficulty: "Intermediate"
documentationLinks: []
downloadableFiles: []
encryptedPayload: "U2FsdGVkX1/AoXBHlOecyhuh5agjjIBGDRA41JZlbgR4Lud1KRKgnPT7yRFwynVWQCaEE24Tzn5YmqEB5ysm63glo6p+nL9PxB2OheXCz8Y="
heroImage: "https://cdn.jsdelivr.net/gh/bigboxthailand/arduino-assets@main/images/projects/diy-piano-make-piano-with-touch-based-keys-touch-sensor-248fbf_cover.jpg"
lang: "en"
likes: 0
passwordHash: "f4c77a9e8982493c25f304efafb56fb7edf8c4d3e9a15eeff8c805961f0af1ec"
price: 99
seoDescription: "Build a DIY Piano with Arduino and Touch Sensors. Play music with a simple touch. An easy and fun electronics project for beginners."
tags:
  - "audio"
  - "arduino"
  - "music"
  - "capacitive touch sensor"
  - "arduino capacitive touch senso"
  - "making touch sensor"
  - "makin piano"
  - "arduino speaker"
  - "arduino speaker"
title: "DIY Piano | Make Piano with Touch based keys | Touch Sensor"
tools: []
videoLinks:
  - "https://www.youtube.com/embed/eIfOWWhDYZo"
  - "https://www.youtube.com/embed/eIfOWWhDYZo"
views: 2626