Introduction: Keyboard Piano

Hi, In this post of instructables, I would like to show you my arduino piano project. Let's jump into it.

What is Arduino?


Well for many peoples who don’t know arduino. Arduino is a microcontroller which helps you to learn electronics and it is also used for playing around. : Arduino has digital and analog pins. Digital is used for giving output. While Analog pins are used for the input of the sensor.

Arduino also has 5v pin which provides 5 volt current.There are many boards of arduino like: Arduino Uno (which we are using in following project) Arduino MegaArduino lilypadArduino NanoAnd many moreSo we’re gonna use arduino uno in our project which you can buy here:https://store.arduino.cc/ and here: https://www.daraz.pk/arduino/

What is Buzzer?

As from the name a buzzer is an electronic device which buzz, or make sound. It is something like this:
A buzzer has two pins. One short and one long. The short pin goes to ground which in symbol means GND. And the longer leg goes to any digital pin.

Things Required:
1) Arduino Uno
2) Buzzer
3)Jumper wires
4) Arduino Software
5) Interest (Lolz)

Code:

/*A project by LearnBtoA.com**/

#include "pitches.h"
int C[] = {N_C5};
int CS[] = {N_CS5};
int D[] = {N_D5};
int DS[] = {N_DS5};
int E[] = {N_E5};
int F[] = {N_F5};
int FS[] = {N_FS5};
int G[] = {N_G5};
int GS[] = {N_GS5};
int A[] = {N_A5};
int AS[] = {N_AS5};
int B[] = {N_B5};
int CC[] = {N_C6};
int duration(500);


void setup() {
pinMode(11, OUTPUT); //Digital Pin 11 is where you connect your Buzzer
Serial.begin(9600);
Serial.println("Buzzer Keyboard!");
Serial.println("Notes: A-S-D-F-G-H-J");
Serial.println("#: Q-W-E-R-T-Y-U");
}
void loop()
{if (Serial.available()) {
char ch = Serial.read();
if (ch == 'a')
{for (int Note = 0; Note < 1; Note++)
{tone(11, C[Note], duration);
}
}
if (ch == 'q')
{for (int Note = 0; Note < 1; Note++)
{tone(11, CS[Note], duration);
}
}
if (ch == 's')
{for (int Note = 0; Note < 1; Note++)
{tone(11, D[Note], duration);
}
}
if (ch == 'w')
{for (int Note = 0; Note < 1; Note++)
{tone(11, DS[Note], duration);
}
}
if (ch == 'd') {for (int Note = 0; Note < 1; Note++)
{tone(11, E[Note], duration);
}
}
if (ch == 'f') {for (int Note = 0; Note < 1; Note++)
{tone(11, F[Note], duration);
}
}
if (ch == 'r') {for (int Note = 0; Note < 1; Note++)
{tone(11, FS[Note], duration);
}
}
if (ch == 'g') {for (int Note = 0; Note < 1; Note++)
{tone(11, G[Note], duration);
}
}
if (ch == 't') {for (int Note = 0; Note < 1; Note++)
{tone(11, GS[Note], duration);}}if (ch == 'h')
{for (int Note = 0; Note < 1; Note++)
{tone(11, A[Note], duration);
}
}
if (ch == 'y') {for (int Note = 0; Note < 1; Note++)
{tone(11, AS[Note], duration);
}
}
if (ch == 'j') {for (int Note = 0; Note < 1; Note++)
{tone(11, B[Note], duration);
}
}
if (ch == 'u') {for (int Note = 0; Note < 1; Note++)
{tone(11, CC[Note], duration);
}
}
}
}
After uploading the code, press Ctrl + Shift + M and type a,s,d,f,g and your buzzer will produce different noises.

Step 1: