Ever wanted to make your Arduino play music? This project will show you how to do just that. Let’s get right to it…
What do you need?
- Windows Computer
- Arduino Integrated Development Environment
- Arduino UNO Microcontroller
- THESE project files
Import Playtune Arudino Library
We’ll need to import an Arduino library that can interpret our MIDI file.
- Extract the project files
2. Open the Arduino IDE
3. Click Sketch > Include Library > Add .ZIP Library
4. Select the playtune.zip file from the selection dialog
Convert the MIDI file
- Move your MIDI file to the project folder or use the one provided.
2. Open a Windows Command Prompt and navigate to the project directory.
3. Execute the following command (be sure to omit the extension .mid from the input fileanme)
miditones -t3 <MIDI Filename without extension HERE>
Back to the IDE
- Open a new sketch in the Arduino IDE
2. Paste the code from song.c file into the new sketch and save it.
3. Replace the C source comment:
// Paste code _HERE_ from converted MIDI file
with the code from the converted midi file
4. Connect your Arduino, upload the sketch, and disconnect it from your computer.
Connect the connections
Connect pins 10, 11, and 12 into the positive wire of the speaker, and ground into the negative wire of the speaker. Once connected properly, connect power to your Arduino and you should hear music.