Introduction: Arduino Touch Piano

Welcome to my instructable. This one contains instructions on how to make a musical instrument using arduino. There are many different unique ways to make noises from an arduino and a cheap speaker. In this example I am using light dependent resistors that act like buttons or piano keys. The instructable will cover setting up the light sensors light buttons and making different tones with a speaker. I also added a RGB LED that changes color based on the keys played but i will not focus on that extra part here. Take small bits from here or the whole thing to create your own electronic instrument.

Step 1: Parts Needed

Picture of Parts Needed
Arduino Uno
Breadboard
Speaker
Light Sensor (LDR)
Jumper cables
10k ohm resistors
USB Cable

Optional:220 ohm resistors
Optional: RGB LED

Step 2: Schematic

Picture of Schematic

Step 3: Variables

Picture of Variables

Here I am assigning variable names. The #define variable lets me write NOTE_C4 instead of 262 which corresponds to the frequency played by the speaker. I named the LDR pins and RGB LED pins so i can keep track of whats what. I also created three variables which will store the reading from each LDR

Step 4: Void Setup() {

Picture of Void Setup() {

Here is where I activate everything I will be using. The speaker Pin and The RGB LED pins are set as OUTPUTS. The LDR pins are set as INPUTS. I also activated the Serial monitor to help with values and bugs. You need to find out what values the LDR reads while covered and uncovered to use in the if statements in the next section of code

Step 5: Void Loop() {

Picture of Void Loop() {

Here is the beginning of the loop function which repeats over and over. The first three lines are used to read and store the values from the LDR's. There are two example if statements shown but there are 7 in total. When a finger is over the LDR the values increase. My values went from around 100 with all light, to around 400 with all darkness. This led me to pick 200 as a nice middle point. Each if statement is for a different combination of keys being pressed. If a statement is true the a special note is played and a color is shown.

Step 6: Void Other Functions (){

Picture of Void Other Functions (){

These are two simple function created to make life easier. This shows what is really happening when i can playTone or set color. this saves some lines of code but if you would like you can put what is in each of these functions in the if statements.

Comments

shaheen king (author)2017-10-27

that`s wonderful <3

jarivkin (author)2017-10-26

This is amazing!!! Best Instructable in the history of the universe!!!!

tliguori330 (author)jarivkin2017-10-26

Thank you, for your kind words stranger

About This Instructable

527views

9favorites

License:

Bio: Always learning.....
More by tliguori330:Doodle Bot With Design ProcessArduino Touch PianoEasy Outdoor Smoker Tips
Add instructable to: