Arduino Christmas tunes player

I made a thing! A festive Arduino thing!

It’s a Christmas tunes player, and lets you choose from four different Christmas songs to play. You select a tune by twisting the potentiometer, and the four LEDs give you feedback as to which song is selected. You then start the song playing by pressing the microswitch.

(OK so technically I made it last year, but have only just gotten round to documenting it now)

If you want to try this out yourself, all the necessary electronics are included in the amazing oomlaut starter kit, and you can get my source code here, which has full instructions in the comments.

Here’s a photo of the circuit itself:

Christmas Tunes circuit

Overhead view of circuit (big image, for great zooming justice)

It’s a bit chaotic on there, so here are the important bits:

  • Piezo speaker
    • Input from: Digital 9
    • Other pin: Ground
  • Potentiometer
    • Output to: Analog In 2
  • Microswitch
    • Output to: Digital 2 (tied to +5V using 10kΩ resistor (brown-black-orange))
    • Other pin: Ground
  • LEDs
    • Inputs from: Digital 3,4,5,6
    • Each LED goes to Ground via a 560Ω resistor (green-blue-brown)

Now obviously it doesn’t have to be a Christmas tunes player – you can put any tunes you want onto it! You can edit the source code and write a different tune using the simple grammar, which basically consists of a string of [note][duration]s, with a full stop (.) at the end. So for example, We Wish You a Merry Christmas looks like this:

d4g4g2a2g2f#2e4c4e4a4a2b2a2g2f#4d4f#4b4b2C2b2a2g4e4d2d2e4a4f#4g8,8.

You can also set a tempo for each song. I won’t bore you with all the details here, but if you want to write your own tunes then there are full instructions over at GitHub.