Making Music With Arduino

by OnTheBrink in Circuits > Speakers

9555 Views, 12 Favorites, 0 Comments

Making Music With Arduino

IMG_0384.jpg
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

work).

I also have a video on this tutorial if you'd like to check that out.

Parts

IMG_0382.jpg

For this project you will need:

  1. Arduino Uno (1)
  2. Piezo Buzzer/8 ohm Speaker (1)
  3. Jumpers (2)
  4. Breadboard (1)
  5. USB B cable (1)

The Circuit

IMG_0381.jpg
IMG_0380.jpg

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!

The Programming

IMG_0383.jpg

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!

Downloads