The BuzzBox
Do you ever wanna pump up some jams but you dont know how to play a MIDI file? Fear not with the new PiicoDev Buzzer modules and a few other bits and bobs you can dance your heart out!
With more than one buzzer you can play chords and depending on the size of the output file, some pretty complex songs!
Whatcha need:
- The number of PiicoDev Buzzers dictates how many notes you can play at once
- A PiicoDev Expansion board
- Some PiicoDev cables (You need a 100mm one to get from one side of the case to the other
- A Raspberry Pi Pico with soldered headers or you can solder your own
- A micro USB cable so you can interact with the Pico
- Something to hold it all together, I went with a 3D printed enclosure for all of the modules (no fasteners required) or if you wanna experiment with some other modules the PiicoDev Pioneers Platform
Putting it together
Here’s where PiicoDev shines, it’s super easy to get everything together.
-
Move each of the DIP switches around into unique addresses - with the 2 switches 4 addresses are possible. Even more with the solder pads on the back (2 more states thats 16 addresses!)
-
Plug in all of the modules using the cables then into the Expansion Board outside of the case helps my daisy chain goes:
Expansion board
50mm cable
Buzzer
50mm cable
Buzzer
100mm cable(underneath the Pico)
Buzzer
50mm cable
Buzzer.
Then throw the Pico(the green one that tastes like Raspberries(PSA: dont lick any Raspberry Pi boards please)) into the expansion board.
Whack all of the electronics into the case/platform of your choice
- Plug the USB cable in, lets flash some code!
First of all lets make 2 folders, one for the Pico and one for the computer code.
Head over to the Buzzer guide for the RPi Pico, run through the tutorial pop the code into the Pico directory and make sure all of the Buzzer modules work - just change theaddr
argumentbuzz = PiicoDev_Buzzer(volume=2, addr=<YOUR ADDRESS HERE>)
Keep the PiicoDev code handy, we’ll need it later!
If you're note sure what the addresses are...
…run the following in the REPL
from machine import I2C
i2c = I2C(0)
i2c.scan()
Then power cycle the Pico - just unplug and plug it back in.
-
Head over to my Git to download the code for the BuzzBox, it leans on the Python-Midi-Analysis Repo that Cornerback24 made.
BuzzBox’s Git Repo
Unfortunately this is too large to run on the Pico, but a Pi Single Board Computer (Pi 4 runs well) can give this program the grunt it needs.
-
To export a MIDI, download a .mid file, and put it in the Midis directory, load up the
MIDI2CSV.py
file and change thefile_to_convert
to the file that you wanna play, run the script, then grab the CSV along with theBuzzerBox.py
andmain.py
(you can overwrite the file from the tutorial) from the Midi’s folder and move it to the same directory that you have the Pico files in.
-
Upload all of the files to the Pico, just change the argument to the loadMusic function
. Click play in Thonny and the Buzzers should start up!!
Feel free to ask questions, Im more than happy to accept feature requests or if you need a hand with anything Liam