Play A Melody

by littleBits

Published on May 15, 2014

Upload this sketch to your Arduino module to play the Jeopardy theme song.

*To complete this exercise, you will need to download the Arduino software.

This sketch uses integer arrays. Integer arrays allow you to store multiple values of the same data type under one name. In this case, the notes of the song are all one data type and the durations for all the notes are another data type. This functionality combined with a for loop makes it easy to write code that references a lot of values.

For more “getting started” sketches, click here.

For support check out the littleBits and Arduino forums.

To learn more about coding, find examples on Arduino’s website.

How To Make It


Download the Arduino software to your computer (it's free!) and open the "Play A Melody" sketch. The "Play A Melody" sketch can be found on this page in the "other files" section.
NOTE: The Play A Melody sketch is zipped in a folder with a supporting file (called a library) named pitches. You'll need to keep these two files in the same folder or the sketch won't work.


Build your circuit (see the photo gallery for an image of the setup). Make sure the speaker is connected to the D9 output pin.


Plug the micro USB cable into both the Arduino module and a USB port on your computer.


Turn your power module on. You should see a red light illuminate on the power module and a yellow light flash on your Arduino module.


In the Arduino program, select your board. Go to Tools>Board>Arduino Leonardo. This littleBits Arduino module is modeled after the Arduino Leonardo and is therefore compatible.


Next select the serial port that the Arduino will communicate over by going back to "Tools" and selecting the correct port in the "Port" section. The name of the port will depend if you are on a Mac or Windows computer. On a Mac, it will start with /dev/tty.usbmodem... and a PC will start with COMM… In Windows, you can look for the USB serial device in the ports section of the Windows Device Manager. If you are on a Linux machine, the port will look like /dev/ttyUSB…


To upload the Arduino sketch to your Arduino module, press the arrow button in the top left corner of the screen. You will see a blue bar at the bottom of the window that says "compiling sketch", and you should see two yellow lights flash on your Arduino module when this happens. The upload is complete when you see "done uploading" at the bottom of your sketch window.


Once the program is uploaded, you will hear the Jeopardy theme song play on the speaker.


You can switch up the song by changing the order of notes and note durations in the code.

Related Projects

Imagin'Lab mini : ma ville connectée avec littleBits Lyon

le 9 Decembre, 2015(Atelier : 8 - 10 ans)Imagin’Lab mini est un format adapté aux enfants qui permet de réaliser un petit pro...

door alarm

this uses the following modules, power, double OR, motion trigger,  sound trigger, a couple of wires, and CloudBit.

Holiday Doorbell

My 8 year old daughter and I used the littleBits basic kit and created a cute holiday doorbell. We picked up a money holder box at...