hi guys have you always wanted to make a piano, if yes, then you are in the right place.
2. 8 ohms speaker
3. Pull down resistors (1k - 10k will do just fine)
4. 8 tact switches
5. Breadboard and veroboard
Step 1: Pull Up and Pull Down Resistors
pull up resistor
This are resistors that keep the logic state of a pin HIGH when the pin is not connected or has no state.
Pull down resistors
This resistors help keep the logic state of a pin low while not connected or when the pin has no state .
To learn more about pull up and pull down resistors visit
Note: there are three pins states which are HIGH, LOW AND floating or high impendence. When a pin is HIGH it means it at 5v (for Arduino MCU) , while LOW means it's is near 0v or GND , while for floating means it has no state it is neither HIGH OR LOW.
NOTE: in this instructables we will be using pull down resistors
Step 2: Tone Fuction and Frequency
Arduino tone fuction
This function is used to generate any frequency at an Arduino pin
tone(pin, frequency, duration or delay) ;
For example tone(9, 3100, 100);
This function is used when you don't want to play any tone or frequency at a particular pin.
For example noTone(9); // this will play no tone or frequency at pin 9.
NOTE: IF u want to change the pin used for the tone make sure it is a PWM pin.
tone(pwm pin, frequency, delay);
noTone(pwm pin); To find out pwm pin for Arduino browse the interne. For example search for (pwm pin of Arduino pro mini). Just change the pro mini to the Arduino micro controller you are using. For more information on pwm visit https://www.arduino.cc/en/Tutorial/PWM
Step 3: Momentary Switches (tact Switches)
This switches when pressed are connected for the moment you pressed them immediately you remove your hand they get disconnected. For more explanations on how to use tact switches download the video in this instructable
Step 4: Schematics
if you are using the code with internal pull up resistor ignore the pull down resistors in this schematics. Remember to connect one lead of your speaker to pwm pin 9 or the pwm pin you are using and the other to GND. if your speaker is polarized connect the positive lead you your pwm pin and the negative pin to GND.
Step 5: Code
The second code was fully modified by me for those who don't have resistors to use as pull down resistors
Code one name is Arduino piano.zip, while code2 is piano.zip
Thank for reading. Play your piano till your souls leap for joy.
I couldn't embed my YouTube video, but you can access it through this link