Skip to content

Arduino Metronome Project

Build a functional metronome with adjustable tempo using an Arduino, a button, a piezo buzzer, and an LED. Perfect for musicians and Arduino beginners.

  • Arduino
  • Beginner
  • 30 to 45 minutes
  • 6 steps

Shop this project

Cart

Prices from vilros.com. Tax and shipping at checkout.

Before you start, you'll need

  • An Arduino Uno (or compatible board) with USB cable
  • A computer with Arduino IDE installed
  • A breadboard and jumper wires
  • A pushbutton, a piezo buzzer, and an LED
  • Resistors: 10kΩ (button pull-down), 330Ω or 470Ω (LED current-limiting)

Set up your Arduino

About 5 minutes

Prepare the Arduino IDE and verify your board is working.

  1. Connect your Arduino Uno to your computer via USB.
  2. Open the Arduino IDE. Select the correct board (Tools → Board → Arduino Uno) and port (Tools → Port).
  3. Upload a simple blink sketch to confirm everything works (File → Examples → 01.Basics → Blink).

You should see

The built-in LED on your Arduino blinks on and off every second.

Wire the pushbutton

About 5 minutes

Connect a pushbutton to control tempo changes.

  1. Place the pushbutton on your breadboard so its pins span the center divide.
  2. Connect one side of the button to Arduino digital pin 2 using a jumper wire.
  3. Connect the same side to GND through a 10kΩ resistor (pull-down configuration).
  4. Connect the other side of the button to 5V.

You should see

The button is firmly seated on the breadboard, and wires connect to pin 2, 5V, and GND.

Wire the piezo buzzer and LED

About 5 minutes

Add audio and visual feedback for each beat.

  1. Connect the piezo buzzer's positive (red) wire to Arduino digital pin 8. Connect its negative (black) wire to GND.
  2. Place an LED on the breadboard. Connect the long leg (anode) to Arduino digital pin 13 through a 330Ω or 470Ω resistor.
  3. Connect the LED's short leg (cathode) to GND.

You should see

Piezo buzzer and LED are wired to pins 8 and 13 respectively, with proper polarity and resistor placement.

Upload the metronome sketch

About 10 minutes

Program the Arduino to produce beats at adjustable tempos.

  1. Open a new sketch in the Arduino IDE and paste the code below.
  2. Click the Upload button (right arrow icon) to upload the sketch to your Arduino.
Arduino C++
// Arduino Metronome Project
// Adjustable tempo using button, piezo buzzer, and LED

const int buttonPin = 2;
const int ledPin = 13;
const int piezoPin = 8;

int tempo = 120; // Initial tempo (beats per minute)
int buttonState = 0;
int lastButtonState = 0;
unsigned long previousMillis = 0;

void setup() {
  pinMode(buttonPin, INPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(piezoPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {
  unsigned long currentMillis = millis();
  unsigned long interval = 60000 / tempo; // Calculate interval from tempo
  
  // Check if it's time for a beat
  if (currentMillis - previousMillis >= interval) {
    previousMillis = currentMillis;
    beat();
  }
  
  // Read button to adjust tempo
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH && lastButtonState == LOW) {
    tempo += 10;
    if (tempo > 240) tempo = 60; // Wrap around after 240 BPM
    Serial.print("Tempo: ");
    Serial.println(tempo);
    delay(200); // Debounce delay
  }
  lastButtonState = buttonState;
}

void beat() {
  digitalWrite(ledPin, HIGH);
  tone(piezoPin, 1000, 50); // 1000 Hz tone for 50ms
  delay(50);
  digitalWrite(ledPin, LOW);
}

This sketch creates a metronome that starts at 120 BPM. Press the button to increase tempo by 10 BPM, wrapping back to 60 after 240.

You should see

The sketch uploads successfully, and the Serial Monitor shows 'Tempo: 120' (open it with Tools → Serial Monitor).

Test and adjust

About 5 minutes

Verify the metronome beats and button control work.

  1. Watch the LED and listen to the piezo buzzer. They should pulse in sync at regular intervals.
  2. Press the button. The tempo should increase by 10 BPM each time you press it.
  3. Open the Serial Monitor (Tools → Serial Monitor) to see the current tempo displayed.

You should see

The LED flashes and the buzzer beeps at regular intervals. Pressing the button increases the tempo, and the Serial Monitor updates.

It didn't work
  • No sound from the piezo buzzer.

    Check that the piezo's positive wire is connected to pin 8 and the negative to GND. Some piezos are quieter than others; try holding it close to your ear.

  • LED doesn't light up.

    Verify the LED's polarity (long leg to pin 13, short leg to GND) and that the resistor is in series. Try a different LED if it still doesn't work.

  • Button doesn't change tempo.

    Check button wiring: one side should go to pin 2 and GND (through 10kΩ), the other side to 5V. Make sure the button straddles the breadboard's center divide.

Make it yours

About 10 minutes

Experiment with tempo range, tone pitch, or LED patterns.

  1. Change the initial tempo by editing the line `int tempo = 120;` to a different value (e.g., 80 or 160).
  2. Adjust the buzzer pitch by changing the `tone(piezoPin, 1000, 50);` line. Try 500 (lower pitch) or 2000 (higher pitch).
  3. Add a second LED or change the LED flash duration by adjusting the `delay(50);` in the `beat()` function.

You should see

Your customizations work as expected: different starting tempo, buzzer pitch, or LED behavior.

What to do next

Stuck? Contact Vilros Support with your board model and what you see on screen.