DIY Metronome

3,520

50

11

Published

Introduction: DIY Metronome

About: Aerospace Engineer working in Software Development with a passion for Hardware.

A metronome is a device that produces an audible beat—a click or other sound—at regular intervals that the user can set in beats per minute (BPM). It is typically used by musicians when practicing on a musical instrument in order to play at a regular pulse. Most metronomes have both an audible click sound synchronized with an inverted pendulum swing.

This uses the Arduino's built in timer to calculate when the next beat is to be played, and adjusts the servo motor to swing the inverted pendulum, as well as give the buzzer the signal to make a 'click' sound.

Step 1: BoM

  • Arduino 101 or Uno
  • Buzzer
  • Servo Motor
  • Popsicle Stick
  • Jumper Wires
  • Hot glue and Hot glue gun
  • [Optional] Breadboard
  • [Optional] Tie wire

Step 2: Connecting the Buzzer

  • Connect one of the buzzer pins to pin 6 on the Arduino with a yellow jumper wire.
  • Connect the remaining buzzer pin to the GND pin on the Arduino with an orange jumper wire.

Step 3: Wiring the Servo Motor

  • Connect the brown pin from the servo motor to the GND pin on the Arduino with a black jumper wire.
  • Connect the red pin from the servo motor to the 5V pin on the Arduino with a red jumper wire.
  • Connect the orange pin from the servo motor to the digital pin 9 on the Arduino with a white jumper wire.

Step 4: Calibrating the Metronome

#include  // attach the servo library
// create a servo variable
Servo metronome;
// declare the constants for the buzzer and servo pins
const int buzz = 6;
const int servo = 9;
void setup() {
  pinMode (buzz, OUTPUT); // set the buzzerpin as an output
  metronome.attach (servo);   //attach the metronome var to a servo pin
  //initialize the angle of the metronome
  metronome.write (105);
}

Step 5: Gluing the Metronome

  • Once the servo arm has been calibrated such that it is 90 degrees from the horizontal, take a piece of popsicle stick and apply glue on the bottom, then stick it parallel to the servo arm.
  • Glue the servo motor long side down, onto a flat surface, I chose my Arduino 101 chassis for this.

Step 6: Coding

You can input the bpm of your metronome in serial monitor and send it off to the Arduino. I opted for a serial monitor signal as opposed to a trim knob since accuracy and precision is important for a metronome, thus sending a known number is more important than an arbitrary analog signal.

#include <Servo.h>  // attach the servo library
// create a servo variable
Servo metronome;
// declare the constants for the buzzer and servo pins
const int buzz = 6;
const int servo = 9;
int centre = 105;
void setup() {
  pinMode (buzz, OUTPUT); // set the buzzerpin as an output
  metronome.attach (servo);   //attach the metronome var to a servo pin
  //initialize the angle of the metronome
  metronome.write (centre);
  Serial.begin (9600);
}
void loop() {

 int bpm = Serial.read();
  metronome.write (105 + 10);
  tone (buzz, 500);
  delay(50);
  noTone (buzz);
  delay(bpm/60*1000);
  tone (buzz, 500);
  delay(50);
  noTone (buzz);
  metronome.write (105 -10);
  delay(bpm/60*1000);
}

Step 7: Done!

Open serial monitor and enter the BPM you want, and play some music to the beat of the metronome!

Makerspace Contest 2017

Second Prize in the
Makerspace Contest 2017

Share

    Recommendations

    • Woodworking Contest

      Woodworking Contest
    • Casting Contest

      Casting Contest
    • Make it Move Contest

      Make it Move Contest
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    11 Comments

    Nice idea! Would love to see video of this thing working / ticking :)

    1 reply

    Unfortunately, I already dismantled it since I needed the servo and Arduino for another project :(

    Very cool, but can a light be additionally added? Perhaps even a 3.5 mm head phone jack?

    1 reply

    An additional light can easily be added by plugging it into one of the digital pins and doing a digitalWrite (pin number, HIGH) and (LOW) right below the tone and noTone, respectively.

    As for the 3.5mm head, it would need a resistor and be plugged in to an analog input, but I don't know exactly how to process it, depending on what data you want.

    I wonder if there is a way to have the Arduino detect the bpm of music and adjust the metronome automatically to suit.would be a cool interactive ornament

    1 reply

    like ptr3777 mentioned, that probably needs a 3.5mm headphone jack and some filters to process the music. I'm not exactly sure how it's gone work, though. Alternatively, a sound detected could be used for distinct beat but it's more of a VU meter (which is another project I just published).

    It looks to me like your delay between beats should be (60*1000/bpm) instead. Try it with 120 bmp (2 beats per second). The way you have it: 120/60 * 1000 = 2000 (or 2 seconds between beats). The other way around you get 60000/120 = 500 or 1/2 second delay.

    1 reply

    Whoops. My brain must have died when I did the math...I'll change that soon. Thanks for flagging the mistake!

    How do you figure it's under $10 when the Uno alone costs over $30, the servo alone is close to $10!

    1 reply

    I based my calculations on eBay/ aliexpress prices because that's where I got some of my parts (others are presents). An Arduino clone is just as good as the orignal cause it's open source.

    nice idea, sure you can improve more your proyect