Table of Contents (TOC)
So, you just learnt how to control a buzzer using an Arduino, but you want more then just simple beeps and hums - you want to assert your dominance over the sound-waves to show-off how well you can control the buzzer.
Cynical? Well there's no denying that it's a sentiment that we all share once we learn something new, but hey, if you've managed to acquire and get an Arduino working, then that's quite far an accomplishment.
A quick search of "music buzzer arduino" should point you to the right direction, but no-one has the time to individually hand-code and map the midi-tones to the frequency values that the Arduino's Tone function requires, especially if you're working with a long MIDI track.
Wiring the Buzzer is trivial, just place the buzzer on two strips (on a breadboard), connect one strip to Pin 11 on your Arduino, and the other strip to the Ground.
Note that this also works with Raspberry Pis.
- Visit: https://www.extramaster.net/tools/midiToArduino/
- Upload a midi file
- Choose the track that you want to export
- Copy the resulting code to a new Arduino sketch
Sample Exported Arduino Code^ TOC
Didn't get the midi file to work with the web app? No worries, here are some sample code generated by the web-apphttps://www.extramaster.net/tools/midiToArduino/
Final Notes^ TOC Oh, and by the way, it appears that you can leave the Piezo buzzer running on loop for an extensive amount of time (24 hours+), so if you want to play a midi indefinitely, you can use an Arduino to do so.
Unfortunately, you can only have one tone running at a time, so if your midi track has multiple keys being played simultaneously, expect some wacky results. (here - try this: http://www.forelise.com/midi - "Track 2: Acoustic Grand Piano - Piano - Fr Elise")
If you attempt some protothreads hack, then expect only one Piezo buzzer to work (at a time). But if you're game, and want to give using protothreads a try: