Starting Electronics Needs Your Help!
It is that time of the year when we need to pay for web hosting and buy new components and equipment for new tutorials. You can help by making a donation. Contribute to this website by clicking the Donate button. The total will be updated once daily. (You may need to clear your browser cache to see the updates.)

Target Amount: $2000
Amount Raised: $118

Donations Received


Tutorial 7: Arduino Melody

Created on: 1 August 2012

A very easy tutorial that uses only two components. The Arduino plays a short melody on a loudspeaker. The program to load to the Arduino is one of the programs that is built into the Arduino IDE.

This video shows the finished circuit in action:

Can't see the video? View on YouTube →


Complete tutorial 3 - Starting with Arduino and its prerequisites before attempting this tutorial.


Besides an Arduino Uno and wire link, you will need:

Qty Part Designator Notes Type
1 100 ohm (brown - black - brown) R1 1/4W, 5% or better Resistors
1 8 ohm loudspeaker SP1 Transducer

The required components are shown in this photo:

Parts needed for the Arduino melody tutorial

Circuit Diagram

The circuit diagram shows that the positive terminal of the speaker is connected through a 100 ohm resistor to pin 8 of the Arduino. The negative terminal of the speaker is connected to one of the Arduino GND pins.

Arduino melody circuit diagram

Building the Circuit

Start by connecting the negative speaker terminal (black wire) to a GND pin on the Arduino. Note that it is not necessary to use a breadboard when using a speaker that is taken from an old PC as it has a connector that a single core wire can be plugged into.

Connect the negative speaker terminal

Connect a 100 ohm resistor to pin 8 of the Arduino and to the positive terminal of the speaker (red wire).

Connect the resistor

Loading the Program

The program to load is one of the built-in Arduino programs. Open it from within the Arduino IDE under:

File → Examples → 2.Digital → toneMelody.

Load the program to the Arduino and the melody will play immediately after loading. To play the melody again, press the reset button on the Arduino.

This project can be found on the Arduino website.

← Go back to Tutorial 6: Rising Pitch SirenGo to Tutorial 8: Dual LED Flasher →