Build it step by step
0 of 8 doneLay out the pads
Two rows of eight buttons on the breadboard.
Wire the grounds
One leg of every button to the ground rail.
Wire the pad signals
Other legs to pins 22 to 37.
Add record and play
Pins 38 and 39.
Add the buzzer
Pin 8 and ground.
Upload the sketch
Press pads to play notes.
Record a tune
Press record, play pads, press record again.
Play it back
Press the play button.
How do you build a sixteen-button sound board?
A Mega with sixteen buttons plays a note on each, like a tiny sampler, with a record button and a play button for short tunes. You need Arduino Mega 2560 R3, Tactile push button 6 mm × 18, Passive buzzer, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points. It takes 8 steps and about 180 minutes.
- Level
- Beginner
- Time
- About 180 min
- Parts
- 5
Parts list
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Pad buttons 1 to 16 | Mega pins 22 to 37 | Each button other leg to GND, uses the internal pull-up |
| Record button | Mega pin 38 and GND | Press to start or stop recording |
| Play button | Mega pin 39 and GND | Plays the recorded tune |
| Passive buzzer positive | Mega pin 8 | Tone output |
| Passive buzzer negative | Mega GND | Common ground |
| Breadboard ground rail | Mega GND | Shared ground for all the buttons |
Code
A Mega has plenty of pins, which makes a sixteen-button pad easy to build. Each button connects a pin to ground, and the internal pull-up resistor holds the pin high until the button is pressed, so no outside resistors are needed. Pins 22 to 37 are used for the pads, and the sketch scans them in a loop and plays a note for the lowest pad that is held, using the tone function on a passive buzzer. The notes are two octaves of a C major scale, so any order of presses sounds reasonable. A record button starts and stops recording, and while it is on, each new note is stored in a list of up to 64 notes. A play button then plays the list back at a fixed speed. A passive buzzer plays only one note at a time, so the pad is monophonic, and when two pads are pressed together the lowest wins. Wire neatly, with one ground rail for all the buttons, and label the pads with tape so you remember which note each one makes. This is a good build for practising tidy wiring with many repeated parts.
Runs on a virtual Arduino Mega 2560 in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
const int FIRST_PAD = 22, PADS = 16;
const int REC_BTN = 38, PLAY_BTN = 39, BUZZ = 8;
// Two octaves of a C major scale, one note per pad
const int NOTES[PADS] = {262, 294, 330, 349, 392, 440, 494, 523,
587, 659, 698, 784, 880, 988, 1047, 1175};
const int MAX_NOTES = 64;
byte tune[MAX_NOTES];
int tuneLen = 0;
bool recording = false;
bool recWas = false, playWas = false;
int heldPad = -1;
void playTune() {
for (int i = 0; i < tuneLen; i++) {
tone(BUZZ, NOTES[tune[i]], 220);
delay(260);
}
noTone(BUZZ);
}
void setup() {
for (int i = 0; i < PADS; i++) pinMode(FIRST_PAD + i, INPUT_PULLUP);
pinMode(REC_BTN, INPUT_PULLUP);
pinMode(PLAY_BTN, INPUT_PULLUP);
Serial.begin(9600);
}
void loop() {
// Find the lowest pad that is held
int pad = -1;
for (int i = 0; i < PADS; i++) {
if (digitalRead(FIRST_PAD + i) == LOW) { pad = i; break; }
}
if (pad != heldPad) {
if (pad >= 0) {
tone(BUZZ, NOTES[pad]);
if (recording && tuneLen < MAX_NOTES) tune[tuneLen++] = pad;
} else {
noTone(BUZZ);
}
heldPad = pad;
}
bool rec = (digitalRead(REC_BTN) == LOW);
if (rec && !recWas) {
recording = !recording;
if (recording) tuneLen = 0; // start a new tune
Serial.println(recording ? "Recording" : "Stopped");
delay(40);
}
recWas = rec;
bool play = (digitalRead(PLAY_BTN) == LOW);
if (play && !playWas && tuneLen > 0 && !recording) {
playTune();
delay(40);
}
playWas = play;
}Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Press pad 1 | Low C, 262 Hz, while held |
| Press pad 16 | High D, 1175 Hz |
| Record a five-note tune | Serial monitor shows Recording then Stopped |
| Press play | The five notes play in order |
| Two pads at once | The lower pad number sounds |
If it does not work
A pad is silent
Check its wire reaches the right pin and the ground rail.
Notes stick on
A button is shorted to ground, check the wiring.
Recording does nothing
Check the record button is on pin 38.
Playback is empty
Record at least one note first.
Buzzer is quiet
Use a passive buzzer on pin 8.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the sixteen-button sound board?
Arduino Mega 2560 R3, Tactile push button 6 mm × 18, Passive buzzer, Jumper wires male to male (40 pcs, 20 cm) and Breadboard 830 Tie Points.
How long does the sixteen-button sound board take to build?
About 180 minutes for a beginner maker, in 8 steps.
How do I know the sixteen-button sound board works?
Press pad 1: Low C, 262 Hz, while held. Press pad 16: High D, 1175 Hz. Record a five-note tune: Serial monitor shows Recording then Stopped.
A pad is silent: what should I check?
Check its wire reaches the right pin and the ground rail.
Notes stick on: what should I check?
A button is shorted to ground, check the wiring.
Recording does nothing: what should I check?
Check the record button is on pin 38.
Playback is empty: what should I check?
Record at least one note first.
