Air Piano Using IR Proximity Sensor and Arduino Uno Atmega 328

by mrfrozenpeak in Circuits > Arduino

2842 Views, 10 Favorites, 0 Comments

Air Piano Using IR Proximity Sensor and Arduino Uno Atmega 328

IMG20200711192435.jpg
15944766113045429829947254042629.jpg
IMG20200711192513.jpg
15944762855631244876533421883095.jpg
15944780957363037065254933178495.jpg
15944765857721583195873175294583.jpg
15944767440516255584367035512443.jpg
15944773814169045121279663714181.jpg
15944781951427176994108673577462.jpg
15944766579776409131173883808796.jpg

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.

Supplies

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

Mounting Ir Sensors

15944792039298029593050377865809.jpg
15944792794362604281689746405520.jpg

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.

Wiring the Sensors

schematic 1_bb.png
IMG20200711192432.jpg

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.

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.

Adjusting Range of Ir Sensor and Covering With Black Carsheet Rolls

15944774111332036602830728359110.jpg
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.

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.

Result

July 11, 2020
July 11, 2020