A little while back, I picked up an Arduino Starter Kit. It contains an Arduino Uno, a bunch of common components, and an instruction book that walks beginners through building circuits and using the Arduino to interact with hardware.
One of the projects in the book is a basic synthesizer that lets you play tones on a piezo speaker. The schematic for this is dead simple:
After getting the Arduino to play a few notes, I decided to extend the project a bit and play a melody. After a bit of screwing around, I managed to get the thing to play the Simpsons theme.
The code for this sketch can be found on GitHub.
This article was originally posted at jonathanfritz.ca