I needed a metronome for my kids practicing piano. Would have been cheaper to buy one, but here we are.
The 3-character LED segment display is from tayda. I found a great article about wiring it up and coding it here. I ended up using the library at the end of the article since it's so simple, but it was nice to read through and understand what's going on in the background.
https://softwareparticles.com/learn...works-and-how-to-control-it-using-an-arduino/
For the audible beats, I ended up just using the Tone() functon. E6 (1319Hz) for the accented beats, and E5 (659Hz) for the non-accented beats. Might clash with some song keys, but I got the idea from a phone app metronome that he was using and it seemed fine. I also considered using some sounds from the Ostman Korg Mini-Pops project (from the blog hoskins site). I think I see how to extract the drum sounds, but setting up the PWM audio interrupts and all seemed like a lot and I was ready to get the project done. Maybe I'll revisit the code at some point.
I also took a shortcut with the code just using the millis() function for the timing, so it isn't perfectly accurate. I think the correct way would be to use interrupts and a more precise counting method, but I’m not that advanced yet and I think it's plenty close.
For the audio output, I used a 2k resistor from Pin11, followed by a 33nF to ground (low pass filter for digital noise). Then a 100uF in series (DC blocking). This is basically from that Ostman Mini-Pops project, or more precisely from the Lauri_DIY youtube video about the Solina project (which also originated from Ostman and was posted on the blog hoskins site). I'm not sure if this filtering is necessary since I'm just using the tone() function, not the super fast pwm audio signal.
Then I run the signal into a little LM386 amp board from amazon (I desoldered the LED and the R2 resistor which cranks the gain too high, and replaced the trimmer with a pot). These boards are really similar to the pedalpcb headphone amp circuit (just the amp part, not the buffer & phase shift part). I've built two of the pedalpcb boards and that phase switch is amazing. But for sneaking a compact single amp in a project, these are great. The speaker came from one of these ISD1820 board kits that I was considering using for a little sampler project (also inspired by a Lauri-DIY video). His videos have a nice calm feel to them so I've watched or listened through several, although he doesn't usually go too deep into the electronics, I like seeing the different approach to DIY, and the music he makes for testing stuff.
Amazon.com: HiLetgo 5pcs LM386 Mono Audio Amplifier Module 200 Times AMP Solo 5V-12V 10K Adjustable : Electronics
Amazon.com: 3Pcs ISD1820 Sound Voice Recording Playback Module with Mic Sound Audio Microphone : Electronics
I relied a lot on JB Weld epoxy for securing the Display, LED, and speaker. This is not coming apart so I hope it doesn’t break. Wiring up the glued in Display (with 11 wires) to the arduino board was rough, and I should have worked out a pcb instead. But, in the end it turned out just as imagined. A typical pedal configuration with everything on the top face would be much easier to design a pcb for. If anyone is interested, I could look into working out a simple pcb for that.
Tayda's drill service for the rectangle display hole and the large circle hole for the speaker were perfect. I may not have attempted the project if I didn't know it would looks so clean.
The 3-character LED segment display is from tayda. I found a great article about wiring it up and coding it here. I ended up using the library at the end of the article since it's so simple, but it was nice to read through and understand what's going on in the background.
https://softwareparticles.com/learn...works-and-how-to-control-it-using-an-arduino/
For the audible beats, I ended up just using the Tone() functon. E6 (1319Hz) for the accented beats, and E5 (659Hz) for the non-accented beats. Might clash with some song keys, but I got the idea from a phone app metronome that he was using and it seemed fine. I also considered using some sounds from the Ostman Korg Mini-Pops project (from the blog hoskins site). I think I see how to extract the drum sounds, but setting up the PWM audio interrupts and all seemed like a lot and I was ready to get the project done. Maybe I'll revisit the code at some point.
I also took a shortcut with the code just using the millis() function for the timing, so it isn't perfectly accurate. I think the correct way would be to use interrupts and a more precise counting method, but I’m not that advanced yet and I think it's plenty close.
For the audio output, I used a 2k resistor from Pin11, followed by a 33nF to ground (low pass filter for digital noise). Then a 100uF in series (DC blocking). This is basically from that Ostman Mini-Pops project, or more precisely from the Lauri_DIY youtube video about the Solina project (which also originated from Ostman and was posted on the blog hoskins site). I'm not sure if this filtering is necessary since I'm just using the tone() function, not the super fast pwm audio signal.
Then I run the signal into a little LM386 amp board from amazon (I desoldered the LED and the R2 resistor which cranks the gain too high, and replaced the trimmer with a pot). These boards are really similar to the pedalpcb headphone amp circuit (just the amp part, not the buffer & phase shift part). I've built two of the pedalpcb boards and that phase switch is amazing. But for sneaking a compact single amp in a project, these are great. The speaker came from one of these ISD1820 board kits that I was considering using for a little sampler project (also inspired by a Lauri-DIY video). His videos have a nice calm feel to them so I've watched or listened through several, although he doesn't usually go too deep into the electronics, I like seeing the different approach to DIY, and the music he makes for testing stuff.
Amazon.com: HiLetgo 5pcs LM386 Mono Audio Amplifier Module 200 Times AMP Solo 5V-12V 10K Adjustable : Electronics
Amazon.com: 3Pcs ISD1820 Sound Voice Recording Playback Module with Mic Sound Audio Microphone : Electronics
I relied a lot on JB Weld epoxy for securing the Display, LED, and speaker. This is not coming apart so I hope it doesn’t break. Wiring up the glued in Display (with 11 wires) to the arduino board was rough, and I should have worked out a pcb instead. But, in the end it turned out just as imagined. A typical pedal configuration with everything on the top face would be much easier to design a pcb for. If anyone is interested, I could look into working out a simple pcb for that.
Tayda's drill service for the rectangle display hole and the large circle hole for the speaker were perfect. I may not have attempted the project if I didn't know it would looks so clean.