Project showcase

Paper Piano with Arduino © GPL3+

This project uses an Arduino, a drawn keyboard using lead pencil, a paper, and a speaker.

  • 23,905 views
  • 36 comments
  • 87 respects

Components and supplies

About this project

This is a simple project using an Arduino, a drawn keyboard using lead pencil, a paper, and a speaker.

Materials

  • Male-to-male jumper wires
  • Breadboard
  • Arduino Uno
  • Resistor 1M ohm
  • Speaker
  • Pencil
  • A4 paper
  • Paper clip
Paper Piano

Capacitive Sensing

Capacitive touch sensing is a way of human touch sensing, that requires little or no force to activate. It may be used to sense human touch through more than a quarter of an inch of plastic, wood, ceramic or other insulating material (not any kind of metal though), enabling the sensor to be completely visually concealed.

Why Capacitive Touch?

  • Each touch sensor requires only one wire connected to it.
  • Can be concealed under any non-metallic mmaterial.
  • Can be easily used in place of a button.
  • Can detect a hand from a few inches away, if required.
  • Very inexpensive.

How Does a Capacitive Sensor Work?

The sensor plate and your body forms a capacitor. We know that a capacitor stores charge. The more its capacitance, the more charge it can store.

The capacitance of this capacitive touch sensor depends on how close your hand is to the plate.

What Does the Arduino Do?

Basically the Arduino measures how much time the capacitor (i.e the touch sensor) takes to charge, giving it an estimate of the capacitance.

The capacitance may be very small, nevertheless the Arduino measures it with accuracy.

One way of using capacitive touch in a project is to use the CapSense library. For the CapSense library, the arduino uses one send pin and any number of receive pins required. A receive pin is connected to the send pin via a medium to high value resistor.

Here are some guidelines for resistors but be sure to experiment for a desired response.

  • Use a 1 megohm resistor (or less maybe) for absolute touch to activate.
  • With a 10 megohm resistor the sensor will start to respond 4-6 inches away.

Code

Paper_piano.inoArduino
// Import the CapacitiveSensor Library.
#include <CapacitiveSensor.h>


 
#define speaker 11


// Set the Send Pin & Receive Pin.
CapacitiveSensor   cs_2_3 = CapacitiveSensor(2,3);        
CapacitiveSensor   cs_2_4 = CapacitiveSensor(2,4);         
CapacitiveSensor   cs_2_5 = CapacitiveSensor(2,5);     
CapacitiveSensor   cs_2_6 = CapacitiveSensor(2,6);     
CapacitiveSensor   cs_2_7 = CapacitiveSensor(2,7);      
CapacitiveSensor   cs_2_8 = CapacitiveSensor(2,8);         
CapacitiveSensor   cs_2_9 = CapacitiveSensor(2,9);  
CapacitiveSensor   cs_2_10 = CapacitiveSensor(2,10);     


void setup()                    
{
  cs_2_6.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate on channel 1 - just as an example
  
  // Arduino start communicate with computer.
  Serial.begin(9600);
}

void loop()                    
{
  // Set a timer.
  long start = millis();
  
  // Set the sensitivity of the sensors.
  long total1 =  cs_2_3.capacitiveSensor(3000);
  long total2 =  cs_2_4.capacitiveSensor(3000);
  long total3 =  cs_2_5.capacitiveSensor(3000);
  long total4 =  cs_2_6.capacitiveSensor(3000);
  long total5 =  cs_2_7.capacitiveSensor(3000);
  long total6 =  cs_2_8.capacitiveSensor(3000);
  long total7 =  cs_2_9.capacitiveSensor(3000);
  long total8 =  cs_2_10.capacitiveSensor(3000);
  


  Serial.print(millis() - start);        // check on performance in milliseconds
  Serial.print("\t");                    // tab character for debug windown spacing

  Serial.print(total1);                  // print sensor output 1
  Serial.print("\t");                    // Leave some space before print the next output
  Serial.print(total2);                  // print sensor output 2
  Serial.print("\t");                    // Leave some space before print the next output
  Serial.print(total3);                  // print sensor output 3
  Serial.print("\t");                    // Leave some space before print the next output
  Serial.print(total4);                  // print sensor output 4
  Serial.print("\t");                    // Leave some space before print the next output
  Serial.print(total5);                  // print sensor output 5
  Serial.print("\t");                    // Leave some space before print the next output
  Serial.print(total6);                  // print sensor output 6
  Serial.print("\t");                    // Leave some space before print the next output
  Serial.print(total7);                   // print sensor output 7
                                          // Leave some space before print the next output
  Serial.print("\t");
  Serial.println(total8);                 // print sensor output 8
                                         // "println" - "ln" represent as "line", system will jump to next line after print the output.
  
  
  
  
  // When hand is touched the sensor, the speaker will produce a tone.
  // I set a threshold for it, so that the sensor won't be too sensitive.
  if (total1 > 500) tone(speaker,131);   // frequency
  if (total2 > 500) tone(speaker,147);   // you can see https://www.arduino.cc/en/Tutorial/toneMelody if you want to change frequency
  if (total3 > 500) tone(speaker,165);
  if (total4 > 500) tone(speaker,175);
  if (total5 > 500) tone(speaker,196);
  if (total6 > 500) tone(speaker,220);
  if (total7 > 500) tone(speaker,247);
  if (total8 > 500) tone(speaker,262);
  
  // When hand didn't touch on it, no tone is produced.
  if (total1<=500  &  total2<=500  &  total3<=500 & total4<=500  &  total5<=500  &  total6<=500 &  total7<=500 &  total8<=500)
    noTone(speaker);

  delay(10);                             // arbitrary delay to limit data to serial port 
}

Schematics

Paper Piano
Paper piano 2 pkxegichqo

Comments

Similar projects you might like

Touch Sensing Paper Piano

Project tutorial by Jeremy Sow

  • 688 views
  • 0 comments
  • 7 respects

Copy of Paper Piano

Project tutorial by user4573

  • 2,002 views
  • 0 comments
  • 5 respects

Electronic Piano Keyboard With Preset Songs

Project tutorial by Lindsay Fox

  • 79,901 views
  • 61 comments
  • 160 respects

Unravel Preset Piano Easy Arduino (Even a Ghoul Can Make It)

Project in progress by ExeCuteLi

  • 5,485 views
  • 8 comments
  • 20 respects

Arduino Paper Controller (Buttons + Slider)

Project tutorial by millerman4487

  • 6,770 views
  • 1 comment
  • 48 respects

PIANO

Project tutorial by يمنى السيد ندا

  • 2,397 views
  • 0 comments
  • 2 respects
Add projectSign up / Login