Introduction: Air Piano Using IR Proximity Sensor, Speaker and Arduino Uno (Upgraded/part-2)

About: Student. For Computer Engineering at VIIT Pune.
This is an upgraded version of the previous project of air piano 🎹. Here I am using a JBL speaker as a output. I have also included a touch sensitive button to change modes according to requirements. For example- Hard Bass mode, Normal mode, High frequency tunes mode. I will show you how to the connected speaker to Arduino. 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.

Supplies

1) 10 pcs Ir proximity sensor

2) Arduino uno/ mega

3) Speaker with audio jack

4) button( In my case touch sensitive button)

5) Base to mount it sensors(acrylic sheet)

6) Black cardsheet/ Black cello tape

7) screws/Glue

8) Wires

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: 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 3: Connecting Speaker to Arduino

Connect one end of audio jack to speaker , the other end usually contains 3 parts. The upper two parts are for left and right inputs and the lower most part is ground. So connect ground of audio jack to ground of Arduino/microcontroller and connect any of right/left part of audio jack to the digital pin of microcontroller. Refer the above image to get a good idea. Turn on your speaker and your audio output is ready.

Step 4: Wiring Ir Sensor Module and Touch Sensor Switch

I am using a touch sensor switch to change the modes of the piano 🎹. You can use a simple push button switch instead. Connect positive terminal of sensor switch to Arduino +5V and negative to ground. Connect output of touch sensor to input of the analog pin of Arduino.
Connect all the positive terminals of ir 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.

Step 5: Code Microcontroller Using Arduino Ide

In this code, we first need to define pins for ir sensor input, touch sensor button input and Speaker output. After that we create a nested array of different frequcies of different modes.
We use tone(); function of Arduino ide to send our output to the speaker. We use noTone(); function to stop the sound. I have only used conditional statement in the loop, so it will be easy to understand and works just fine.

Step 6: Video of Project Working