Arduino Cap-Sense Air Piano

Introduction: Arduino Cap-Sense Air Piano

About: An aspiring artist. Visit me at
I recently got my shipment of 10 buzzers I ordered about a month ago, so as soon as I got them I was eager to make something fun with them, so I looked around a bit and searched for what to do with them, and by spending some time on www.arduino,cc and posting lots of questions on the forums, I figured out what I am going to make.

I decided to make an air piano which is based upon cap-sense and the arduino.

  • Aluminum tape or aluminum foil
  • Some wires
  • 8 10M Ohm resistors
  • Piezo buzzer
  • Arduino
  • 9V battery or USB cable

Basically, there are square pieces of aluminum tape stuck onto a thick card which is attached to a jumper cable and a resistor, 8 replicas of this are made, then all the other ends of the resistors are attached together and to pin3 of the arduino, this will act as the common base pin for all the sensors. The resistor values can be 2M or 10M or 40M Ohm. 2M Ohm will make it so that it only senses when you press on the aluminum tape, 10M Ohm resistor makes it so that your hand can be sensed at a little height of 3-5cm or so and 40M Ohm will sense quite a bit further, but it gets a little messy as if the aluminum tape pieces are too close together then at that height interference occurs therefore other keys might get pressed. If you want to use this 40M Ohm version then you have to make sure to place the aluminum tape pieces a little far away from each other.
I used 10M Ohm for my device and it works perfectly when I wave my hand over the note I want to use.

The basic principle behind this is that the aluminum tape detects the difference between human body capacitance and the capacitance of air, or in other words the aluminum tape is given a small voltage by the arduino which creates an electrical field in that area, and when our finger(being a conductor) touches it, we form a capacitor. This change is detected by the aluminum tape and therefore sends a signal to the arduino with which we can tell it to send a signal to the buzzer.
I have heard that we can also use resistive sensing instead of capacitive but I'm not exactly sure how it works.

I attached a good piezo buzzer to pin A0 or Analogue Pin 0, the common pin to pin 3 and the 8 different squares of aluminum tape to 4,5,6,7,8,9,10,11 pins.

Schematic in one of the images attached to this instructable.

This is the code I used;
#include "pitches.h"

#define COMMON_PIN      3   
#define BUZZER_PIN      A0  
#define NUM_OF_SAMPLES  1  
#define CAP_THRESHOLD   100 
#define NUM_OF_KEYS     8 

#define CS(Y) CapacitiveSensor(2, Y)


CapacitiveSensor keys[] = {CS(4), CS(5), CS(6), CS(7), CS(8), CS(9), CS(10), CS(11)};

void setup()
  for(int i=0; i<8; ++i)

void loop()
  for (int i = 0; i < 8; ++i)
    if(keys[i].capacitiveSensor(NUM_OF_SAMPLES) > CAP_THRESHOLD)
      tone(BUZZER_PIN, notes[i]);
What the code does is first include the 2 libraries, capacitivesensors.h and pitch.h, pitch.h is used for using the tone command with notes such as A2,B6,F2 etc instead of frequencies themselves.Then it defines the pins and the capacitor threshold, this is basically the amount of "sensing" the capacitor does, if you reduce it then the sensor detects more easily if increased it does the opposite.
Then you are defining the notes for each key pressed, and then you define the pins the keys or aluminum tape pieces are connected to.
In void setup you set buzzer pin as output and you set calibration to 0.
In the void loop you are saying that if the tape detects your finger, then the if statement gets executed, therefore the buzzer is played with the respective note. If that does not happen then since there is no else function, it just goes through void loop again.

The tone() command sets the tone to be played on the buzzer, you can also use the tone command to play separate plain notes as tone(pin, frequency, duration) but we use notes here with the pitch.h so we do not need to bother with that.

Its a rather simple hardware build which offers a lot of learning in the software side.
Its a recommended project for beginners who don't have a lot of hardware material but are willing to learn how the software works in the arduino ide.

According to me its a great fun to do project and doesn't take long either.
You can also adjust the notes to make all sorts of different fun tunes like umm....maybe an alien voice? or a radio tuner?

Hope to see what others do with this Cap-Sense arduino combination, and if anyone makes this it would be awesome if you shared pictures of the finished project :)

  1. Cap-sense Arduino Library ;

  1. (Idea Start)
  2. (How does Cap-sense work)
  3. (Initiative for Cap-sense)
  4. (More Inspiration)
  5. (Inspiration for making a piano)
  6. Tyler Crumpton, J Z Chen and Nicholas Jones were the people who worked around with this technology to make all sorts of things so all the credit goes to them.
Brief Video; (Cap-Sense Air Piano)

Kit Contest

Participated in the
Kit Contest

Be the First to Share


    • Make It Bridge

      Make It Bridge
    • For the Home Contest

      For the Home Contest
    • Big and Small Contest

      Big and Small Contest



    9 years ago on Introduction

    what should i change from the code to use it in fl studio? Thanks