Projects / Sixteen-button sound board

Sixteen-button sound board

Beginner3 hGuided buildReviewed

Build it step by step

0 of 8 done
  1. MEGA

    Lay out the pads

    Two rows of eight buttons on the breadboard.

  2. MEGA

    Wire the grounds

    One leg of every button to the ground rail.

  3. MEGA

    Wire the pad signals

    Other legs to pins 22 to 37.

  4. MEGA

    Add record and play

    Pins 38 and 39.

  5. MEGA

    Add the buzzer

    Pin 8 and ground.

  6. MEGA

    Upload the sketch

    Press pads to play notes.

  7. MEGA

    Record a tune

    Press record, play pads, press record again.

  8. MEGA

    Play it back

    Press the play button.

In short

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

FromToWhy
Pad buttons 1 to 16Mega pins 22 to 37Each button other leg to GND, uses the internal pull-up
Record buttonMega pin 38 and GNDPress to start or stop recording
Play buttonMega pin 39 and GNDPlays the recorded tune
Passive buzzer positiveMega pin 8Tone output
Passive buzzer negativeMega GNDCommon ground
Breadboard ground railMega GNDShared 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.

CheckExpected
Press pad 1Low C, 262 Hz, while held
Press pad 16High D, 1175 Hz
Record a five-note tuneSerial monitor shows Recording then Stopped
Press playThe five notes play in order
Two pads at onceThe 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 →

Ask Lark AI

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.