This is a simple Python script that converts a MIDI file into an Arduino sketch that plays the MIDI file on a Piezo buzzer. This was made originally for a school project, but I decided to make it public for anyone who wants to use it.
- Activate the virtual environment by running
source venv/bin/activate
. - Move the MIDI file you want to convert into the
midi
directory. - Edit
main.py
to use the correct MIDI file. - Run
python main.py
. - In the Arduino IDE, open the
playMelody.ino
sketch and upload it to your Arduino. - Connect a piezo buzzer to pin 8 and ground on your Arduino.
- Power the Arduino and listen to the melody!