In this project, we’ll see how to make a piano with Arduino. For this, we’ll use push buttons. Each push button has its own note. We’ll see how to change the notes and add more as well. Required materials Now, here are the materials needed for the project:An Arduino Uno boardA buzzer8 push buttons8 resistors, 10 kilo-ohms eachJumper wires What are the resistors for? Resistors are used as pull-up resistors to prevent a floating (high-impedance) state when the push button is pressed. For more information about the floating state, you can check out our course on the topic. How does the buzzer work? We will also use a buzzer that produces sound from an analog input. Depending on the voltage across the buzzer, it will emit different sounds. /* Arduino Factory Piano Code */ // Define the push buttons int Button_1 = 2; int Button_2 = 3; int Button_3 = 4; int Button_4 = 5; int Button_5 = 6; int Button_6 = 7; int Button_7 = 8; int Button_8 = 9; // Define the buzzer int buzzer = 13; void setup() { // Set push buttons as inputs (pull-up) pinMode(Button_1, INPUT); pinMode(Button_2, INPUT); pinMode(Button_3, INPUT); pinMode(Button_4, INPUT); pinMode(Button_5, INPUT); pinMode(Button_6, INPUT); pinMode(Button_7, INPUT); pinMode(Button_8, INPUT); // Set buzzer as output pinMode(buzzer, OUTPUT); } void loop() { // Read the values from the push buttons int b1 = digitalRead(Button_1); int b2 = digitalRead(Button_2); int b3 = digitalRead(Button_3); int b4 = digitalRead(Button_4); int b5 = digitalRead(Button_5); int b6 = digitalRead(Button_6); int b7 = digitalRead(Button_7); int b8 = digitalRead(Button_8); // If a button is pressed, play the buzzer with the corresponding note if (b1 == 1) { tone(buzzer, 240, 100); } if (b2 == 1) { tone(buzzer, 270, 100); } if (b3 == 1) { tone(buzzer, 300, 100); } if (b4 == 1) { tone(buzzer, 337.5, 100); } if (b5 == 1) { tone(buzzer, 360, 100); } if (b6 == 1) { tone(buzzer, 400, 100); } if (b7 == 1) { tone(buzzer, 450, 100); } if (b8 == 1) { tone(buzzer, 470, 100); } delay(10); // Pause between notes }