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