Arduino Project · Kids Series
Kids Piano Circuit
with 8 Keys
Build a mini playable piano using an Arduino UNO and a piezo buzzer — perfect for school exhibitions and STEM classrooms.
🎹 Try the Piano — Click or Press Keys 1–8
Click keys above · or press keyboard 1 2 3 4 5 6 7 8
1 Components Required
Arduino UNO
× 1
Push Buttons
× 8
Piezo Buzzer
× 1
10kΩ Resistors
× 8 (pull-down)
Breadboard
× 1 (830-point)
Jumper Wires
Male-to-Male
When a child presses any of the 8 buttons, the piezo buzzer plays a corresponding note (C4 to C5), making it a simple, interactive piano toy. It's a great way to introduce kids to electronics and music!
CODE:
Try this using tinkercad:
2 Circuit Diagram
⚠️ Dashed lines represent wire connections. Avoid D0 & D1 — reserved for serial communication.
3 Step-by-Step Instructions
1
Set up the power rails on the breadboard
Connect Arduino's 5V pin to the breadboard's red (+) power rail and GND to the blue (−) rail using jumper wires.
💡 Use red wire for 5V and black wire for GND — a colour convention that prevents confusion.
2
Place all 8 push buttons on the breadboard
Space the buttons across the breadboard. Each button straddles the center gap of the breadboard so both sides are accessible independently.
3
Wire one leg of each button to 5V
Connect the left leg of each button to the red (+) power rail. This means pressing the button sends a HIGH signal to the Arduino.
4
Add pull-down resistors (10kΩ)
Connect a 10kΩ resistor from the right leg of each button to the GND rail. This ensures the pin reads LOW when the button is not pressed (prevents floating inputs).
⚠️ Without pull-down resistors, the input pins will "float" and give random readings.
5
Connect buttons to Arduino digital pins D2–D9
Wire the right leg of each button (same node as the resistor) to the corresponding Arduino pin: Button 1 → D2, Button 2 → D3, … Button 8 → D9.
6
Connect the piezo buzzer
Place the buzzer on the breadboard. Connect its positive leg (+) to Arduino pin D10. Connect its negative leg (−) to the GND rail.
7
Upload the code & test
Paste the Arduino code below into the IDE, select Arduino UNO as the board, and upload. Press each button — you should hear the corresponding note!
⚠️
Do not use digital pins D0 and D1 — these are reserved for serial (TX/RX) communication and will conflict with the USB connection used for programming.
4 Notes & Frequencies
Button
Arduino Pin
Note
Frequency (Hz)
1 D2 C4 262
2 D3 D4 294
3 D4 E4 330
4 D5 F4 349
5 D6 G4 392
6 D7 A4 440
7 D8 B4 494
8 D9 C5 523
5 Arduino Code
kids_piano.ino
// Kids Piano — 8 Keys | MakeMindz.com
const int buzzer = 10;
int buttons[8] = {2, 3, 4, 5, 6, 7, 8, 9};
int notes[8] = {262, 294, 330, 349, 392, 440, 494, 523};
// Notes: C4 D4 E4 F4 G4 A4 B4 C5
void setup() {
for (int i = 0; i < 8; i++) {
pinMode(buttons[i], INPUT);
}
pinMode(buzzer, OUTPUT);
}
void loop() {
// Check each button — play note if pressed
for (int i = 0; i < 8; i++) {
if (digitalRead(buttons[i]) == HIGH) {
tone(buzzer, notes[i]);
}
}
// Stop buzzer when no button is pressed
if (
digitalRead(2) == LOW &&
digitalRead(3) == LOW &&
digitalRead(4) == LOW &&
digitalRead(5) == LOW &&
digitalRead(6) == LOW &&
digitalRead(7) == LOW &&
digitalRead(8) == LOW &&
digitalRead(9) == LOW
) {
noTone(buzzer);
}
}
7 Try the Simulation
🎮 Run it in Tinkercad
No hardware? No problem. Open the full simulation — press buttons to hear notes play in real time inside your browser.
▶ Open Tinkercad Sim
8 How It Works
Button Pressed
Sends a HIGH signal to the Arduino digital pin via the 5V rail.
Arduino Reads Input
digitalRead() detects HIGH and looks up the matching frequency in the notes array.
Square Wave Generated
tone(buzzer, freq) generates a square wave at the correct Hz on pin D10.
Sound Plays
The piezo buzzer converts the electrical signal into audible musical notes.
9 Learning Outcomes
⚡ Digital input / output (I/O)
📋 Arrays in Arduino C++
🎵 Sound frequency basics
🔌 Pull-down resistor circuits
🔁 For-loop logic
🎹 Interactive electronics design
2 Circuit Diagram
⚠️ Dashed lines represent wire connections. Avoid D0 & D1 — reserved for serial communication.
3 Step-by-Step Instructions
1
Set up the power rails on the breadboard
Connect Arduino's 5V pin to the breadboard's red (+) power rail and GND to the blue (−) rail using jumper wires.
💡 Use red wire for 5V and black wire for GND — a colour convention that prevents confusion.
2
Place all 8 push buttons on the breadboard
Space the buttons across the breadboard. Each button straddles the center gap of the breadboard so both sides are accessible independently.
3
Wire one leg of each button to 5V
Connect the left leg of each button to the red (+) power rail. This means pressing the button sends a HIGH signal to the Arduino.
4
Add pull-down resistors (10kΩ)
Connect a 10kΩ resistor from the right leg of each button to the GND rail. This ensures the pin reads LOW when the button is not pressed (prevents floating inputs).
⚠️ Without pull-down resistors, the input pins will "float" and give random readings.
5
Connect buttons to Arduino digital pins D2–D9
Wire the right leg of each button (same node as the resistor) to the corresponding Arduino pin: Button 1 → D2, Button 2 → D3, … Button 8 → D9.
6
Connect the piezo buzzer
Place the buzzer on the breadboard. Connect its positive leg (+) to Arduino pin D10. Connect its negative leg (−) to the GND rail.
7
Upload the code & test
Paste the Arduino code below into the IDE, select Arduino UNO as the board, and upload. Press each button — you should hear the corresponding note!
⚠️
Do not use digital pins D0 and D1 — these are reserved for serial (TX/RX) communication and will conflict with the USB connection used for programming.
4 Notes & Frequencies
| Button | Arduino Pin | Note | Frequency (Hz) |
|---|---|---|---|
| 1 | D2 | C4 | 262 |
| 2 | D3 | D4 | 294 |
| 3 | D4 | E4 | 330 |
| 4 | D5 | F4 | 349 |
| 5 | D6 | G4 | 392 |
| 6 | D7 | A4 | 440 |
| 7 | D8 | B4 | 494 |
| 8 | D9 | C5 | 523 |
5 Arduino Code
kids_piano.ino
// Kids Piano — 8 Keys | MakeMindz.com const int buzzer = 10; int buttons[8] = {2, 3, 4, 5, 6, 7, 8, 9}; int notes[8] = {262, 294, 330, 349, 392, 440, 494, 523}; // Notes: C4 D4 E4 F4 G4 A4 B4 C5 void setup() { for (int i = 0; i < 8; i++) { pinMode(buttons[i], INPUT); } pinMode(buzzer, OUTPUT); } void loop() { // Check each button — play note if pressed for (int i = 0; i < 8; i++) { if (digitalRead(buttons[i]) == HIGH) { tone(buzzer, notes[i]); } } // Stop buzzer when no button is pressed if ( digitalRead(2) == LOW && digitalRead(3) == LOW && digitalRead(4) == LOW && digitalRead(5) == LOW && digitalRead(6) == LOW && digitalRead(7) == LOW && digitalRead(8) == LOW && digitalRead(9) == LOW ) { noTone(buzzer); } }
7 Try the Simulation
🎮 Run it in Tinkercad
No hardware? No problem. Open the full simulation — press buttons to hear notes play in real time inside your browser.
8 How It Works
Button Pressed
Sends a HIGH signal to the Arduino digital pin via the 5V rail.
Arduino Reads Input
digitalRead() detects HIGH and looks up the matching frequency in the notes array.Square Wave Generated
tone(buzzer, freq) generates a square wave at the correct Hz on pin D10.Sound Plays
The piezo buzzer converts the electrical signal into audible musical notes.
9 Learning Outcomes
⚡ Digital input / output (I/O)
📋 Arrays in Arduino C++
🎵 Sound frequency basics
🔌 Pull-down resistor circuits
🔁 For-loop logic
🎹 Interactive electronics design

Comments
Post a Comment