Projects / Eight-key buzzer piano

Eight-key buzzer piano

Beginner45 minGuided buildReviewed

Build it step by step

0 of 4 done
  1. UNO

    Lay out the keys

    Put eight buttons in a row across the breadboard gap like piano keys, and the ninth apart.

  2. UNO

    Wire the keys

    One side of each button to D2...D9 (and D12), the other side to the GND rail.

  3. UNO

    Wire the buzzer

    D11 through 100 Ω to the buzzer plus, minus to GND.

  4. UNO

    Upload and play

    Play C to C, then press the ninth button.

In short

How do you build an eight-key buzzer piano?

Eight push buttons play the notes of one octave (C to C) on a passive buzzer, and a ninth button plays a short tune. You need Arduino Uno R3, Passive buzzer, Tactile push button 6 mm × 9, Resistor 100 Ω, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). It takes 4 steps and about 45 minutes.

Level
Beginner
Time
About 45 min
Parts
6

Parts list

Tick what you already own. It saves to My Garage, so “Build with what I have” knows.

Wiring

FromToWhy
Buttons 1 to 8Uno D2 to D9, other side to GNDNotes C D E F G A B C
Button 9Uno D12 and GNDPlay a tune
Uno D11100 Ω to buzzer +, buzzer − to GNDSound

Code

Arduino IDE, board "Arduino Uno". tone() is built in. A passive buzzer is needed: an active buzzer only makes one fixed beep.

Runs on a virtual Arduino Uno 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 KEYS[8] = {2, 3, 4, 5, 6, 7, 8, 9};
const int NOTES[8] = {262, 294, 330, 349, 392, 440, 494, 523};   // C4 to C5 in Hz
const int BUZZER = 11, SONG = 12;
// "Sa Re Ga Ma" warm-up: C D E F G F E D C
const int TUNE[] = {262, 294, 330, 349, 392, 349, 330, 294, 262};

void setup() {
  for (int k : KEYS) pinMode(k, INPUT_PULLUP);
  pinMode(SONG, INPUT_PULLUP);
}

void loop() {
  for (int i = 0; i < 8; i++) {
    if (digitalRead(KEYS[i]) == LOW) {
      tone(BUZZER, NOTES[i]);
      while (digitalRead(KEYS[i]) == LOW) {}   // hold the note while pressed
      noTone(BUZZER);
    }
  }
  if (digitalRead(SONG) == LOW) {
    for (int f : TUNE) { tone(BUZZER, f, 300); delay(350); }
  }
}

Test checklist

What you should see at each check. If a reading is far off, stop and use the troubleshooting list.

CheckExpected
Button 1Low C (262 Hz)
Button 8High C, clearly an octave above button 1
Ninth buttonC D E F G F E D C
Holding a keyThe note lasts as long as you hold it

If it does not work

Only a click, no note

You have an active buzzer, or it is backwards. Use a passive one.

A key plays nothing

Check that button spans the breadboard gap and its pin number.

Notes sound out of tune

Small buzzers are not flat across frequencies. A small 8 Ω speaker with the 100 Ω sounds better.

Still stuck? Find the fault step by step with your multimeter →

Ask Lark AI

Common questions

What parts do I need for the eight-key buzzer piano?

Arduino Uno R3, Passive buzzer, Tactile push button 6 mm × 9, Resistor 100 Ω, Breadboard 830 Tie Points and Jumper wires male to male (40 pcs, 20 cm). Resistor 100 Ω: In series with the buzzer.

How long does the eight-key buzzer piano take to build?

About 45 minutes for a beginner maker, in 4 steps.

How do I know the eight-key buzzer piano works?

Button 1: Low C (262 Hz). Button 8: High C, clearly an octave above button 1. Ninth button: C D E F G F E D C.

Only a click, no note: what should I check?

You have an active buzzer, or it is backwards. Use a passive one.

A key plays nothing: what should I check?

Check that button spans the breadboard gap and its pin number.

Notes sound out of tune: what should I check?

Small buzzers are not flat across frequencies. A small 8 Ω speaker with the 100 Ω sounds better.