Introduction: Making Music With Arduino
Hello Everybody! Today, I'm going to show you how to play your favorite songs on Arduino (if you're up for some
I also have a video on this tutorial if you'd like to check that out.
Step 1: Parts
For this project you will need:
- Arduino Uno (1)
- Piezo Buzzer/8 ohm Speaker (1)
- Jumpers (2)
- Breadboard (1)
- USB B cable (1)
Step 2: The Circuit
All you have to do for this is connect the cathode of the Piezo buzzer to GND and the anode to pin 8 of the Uno board. The programming is where all of the hard work is located, so get ready!
Step 3: The Programming
Alright, let's get right in to this. I do not know what your favorite song is, so I cannot provide you with the code or playing said song. However, I can supply you with a template for making such a program. Don't worry, I'll explain the template for you. First off, you have a lot of #define's to set the frequency of the basic notes. These commands associate the names of the notes to their actual frequencies. After that, you have a few more #define's for timing ( e.g. whole, half, quarter note). Next, you have to set the pin for your buzzer, which I set as pin 8. Then, you have your void setup, which sets the buzzer as an output. Finally, you have the void loop, which is where you will need to transcribe your song with the tone() command. This command takes three arguments, pin number, note and duration, which are all pretty self explanatory. Transcribing your song will take a while, but it's well worth it. One thing I'm going to do in the next revision of this project is to use an Arduino Nano, an audio jack and an earphone to make a portable music player, kind of like a very specialized iPod. Anyway, thanks for reading, and as always, Happy Making!
Participated in the
Makerspace Contest 2017