Metronome Circuit With Attiny-45

by tszebeni in Circuits > Arduino

520 Views, 0 Favorites, 0 Comments

Metronome Circuit With Attiny-45

metronome.jpeg

This is a simple circuit to produce metronome for my oldest son when he learns to play on violin, controlled by 2 toggles (4 options for frequency). To generate tone on the buzzer.

Supplies

  • attiny45 or other Arduino IDE supported microcontroller
  • Some arduino board to program the attiny chip or some programmer hardware
  • CR2032 battery and holder
  • buzzer
  • 100microF capacitor
  • On/Off switch
  • 2 toggle switches

Program Attiny45

You can program your microcontroller by using Arduino IDE. The two toggles use the internal pull up resistor so there is no need to add additional components to the circuit.


Program:


int buzzer = 0; // buzzer pin

int mode1 = 1; // toggle1 pin

int mode2 = 2; // toggle2 pin


// frequency config for 4 available options

int bpm[] = {60,90,120,150};


void setup() {

 pinMode(buzzer, OUTPUT);

 pinMode(mode1, INPUT_PULLUP);

 pinMode(mode2, INPUT_PULLUP);

}


void loop() {

 // read toggles

 int m1 = digitalRead(mode1);

 int m2 = digitalRead(mode2);

 // calculate index for frequency

 int i = (m1 == HIGH ? 0 : 1) * 2 + (m2 == HIGH ? 0 : 1);

 int dly = 60000/bpm[i];

 tone(buzzer, 400, 100);

 delay(dly);

}

Downloads

Solder the Parts

circuit.png

You can follow the circuit diagram to solder the parts. For simplicity the most components positive side is facing the microcontroller and their other side is connected to ground.