Introduction: DIY Metronome

Picture of DIY Metronome

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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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!

Picture of Done!

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

Comments

ArkadiuszR1 (author)2017-08-10

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

TechMartian (author)ArkadiuszR12017-08-10

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

ptr3777 (author)2017-08-10

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

TechMartian (author)ptr37772017-08-10

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.

RobB26 (author)2017-08-10

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

TechMartian (author)RobB262017-08-10

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).

CompositeKid (author)2017-08-10

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.

TechMartian (author)CompositeKid2017-08-10

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

chopper109 (author)2017-08-10

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

TechMartian (author)chopper1092017-08-10

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.

JuanA210 (author)2017-08-10

nice idea, sure you can improve more your proyect

About This Instructable

2,900views

50favorites

License:

Bio: Aerospace Engineer working in Software Development with a passion for Hardware.
Add instructable to: