Air Piano Using IR Proximity Sensor and Arduino Uno Atmega 328




Introduction: Air Piano Using IR Proximity Sensor and Arduino Uno Atmega 328

About: Student. For Computer Engineering at VIIT Pune.

Normally Pianos be it electric or mechanical work on the simple mechanism of pushing button. But here is a twist, we could just eliminate the need of keys in a piano by using some sensors. And Infra-red Proximity sensors best fit the cause because they are easy to use and they also occupy just one digital pin of microcontroller board. And also these sensors are one of the cheapest sensors available out there. I am using a buzzer as a musical output, but you can use a proper speaker/ subwoofer . In future I look forward to upgrade the project with bass boost using Subwoofer.


1) 10 pcs Ir proximity sensor

2) Arduino uno/ mega

3) screws (optional)

4) Wires

5) Piezo-electric Buzzer

6) Black cardsheet/ Black cello tape

Step 1: Mounting Ir Sensors

Ir sensor modules are equipped with a mounting hole at the center. You could use the hole to fit sensor with a tight screw or you can just use glue to stick it. I have used an acrylic sheet as base and drilled holes in acrylic with proper markings where each hole was 2 cm apart. Do not arrange the sensors too close to each other as it may ruin your piano user experience.

Step 2: Wiring the Sensors

Connect all the positive terminals of sensors using a wire and solder(optional). Also connect all the ground pins of all the sensors. Now finally, you need to connect output pins from Ir sensor to Digital pins of the microcontroller board. In my case, it is Arduino uno. Remember that , when an obstacle is detected Output from the sensor is low. So, if you want to connect led as indicator in the circuit, connect the negative terminal to sensor output and positive to 3.3v positive rail of Arduino uno.

Step 3: Connecting Output

Now connect the the digital output pin to the positive terminal of buzzer/ speaker. And connect the negative terminal to the ground of Arduino uno. If you are using a buzzer/ speaker which requires a high voltage, it is recommended to use a npn bjt because it has very fast switching and can run smoothly with variable frequency inputs from Arduino. Also make sure that if you are using high power buzzer, don't use power supply from arduino. Instead use some external source but in my case power consumption is low so I am using directly from Arduino.

Step 4: Adjusting Range of Ir Sensor and Covering With Black Carsheet Rolls

Use the potentiometer on it sensor module to adjust the suitable range for your piano keys. Now mount the black cardsheet rolls on it sensor module led and photo-diode as shown in picture. This is done to prevent detection of unwanted obstacle in other direction. We want to detect fingers only in the front. And we use black cardsheet because black absorbs all wavelengths and even infra reds.

Step 5: Code for Micro-controller Board

The code begins with defining frequencies for which we want output of buzzer/speaker. Then we define pins which we are going to use for sensor inputs. Then we setup our pins in void setup(). In void loop() I have just used conditional statements because code becomes simple and is good enough for present needs.

Step 6: Result

Audio Challenge 2020

Participated in the
Audio Challenge 2020

Be the First to Share


    • Microcontroller Contest

      Microcontroller Contest
    • Teach With Tinkercad Contest

      Teach With Tinkercad Contest
    • Fandom Contest

      Fandom Contest