Although we have hitherto made noises with the Arduino we've used a piezo buzzer to do it and the response has been somewhat less than high fidelity and at an audible level not much greater than the threshhold of hearing. If we use a dynamic loudspeaker, we can give the board a much bigger mouth.

So, firstly you might be asking "what is a dynamic speaker?" and so let's have a look, aided by a diagram from our old friends the United States Navy:

Adding a Speaker to your Arduino

Go Back

In the middle there is the voice coil, which is a lot of copper wire wound round in, unsurprisingly, a coil.The coil is free to move in the air gap, but it's attached to the speaker cone. When you send a current through it, it becomes a magnet, and reacts with the permanent magnet behind by either moving away from it or towards it. This causes the cone to move too, but since the outsides of the cone are attached to the basket (outside) of the speaker, the cone stretches and contracts, causing a rarefaction or compression of the air next to it, which travels until it hits your eardrum and causes a sound. It's very clever stuff.

This is a small speaker looking from the front. The cone here is made out of mylar, which is a kind of plastic. The advantage of this is that it is more resilient than the usual kind, which is made of stiff paper, the disadvantage is that it is not as responsive.

On the left here you can see a standard paper speaker as sold by Rapid Electronics of Colchester. On the back of it you can see it declares itself to be an 8 ohm speaker with a power rating of 0.3 Watts. That's ideal for what we want.

The 8 ohm rating is very important. We have to match the impedance of the speaker with what we expect the output impedance of the Arduino to be. In this way we get maximum power transfer between the two. If we have too much power on one or the other side, we run the risk of damage. In terms of Wattage, you could use a speaker rated as low as 0.25W if you like; no harm will come to the speaker or your Arduino.

Speakers rarely come with wires attached and so if you are using a new one you'll have to do a bit of soldering. The wires go on to those two protruding lugs at the back, and you may want to twist them together a few times to get some strain relief. For breadboarding, you need solid core not stranded.

The 8 ohm loud speaker needs its impedance increasing a little bit to work succesfully and reliably with your arduino board. Attach a resistor to pin 10, of a value of between 100 and 120 ohms, and connect one wire of the loudspeaker to the other end of the resistor. The other wire goes to GND. Now upload the following code:



//Ian Lang////////

int (nl)=19;

int (f[]) ={392,294,392,294,392,294,392,492,588,0,522,440,522,440,522,440,370,440,294}; //sets frequencies

int (d[]) ={2,1,2,1,1,1,1,1,2,2,2,1,2,1,1,1,1,1,2};

void setup () {




void loop (){

  for (int j=0; j<nl;j=j+1){//loop for nl value

    tone (10,f[j],200*d[j]); // tone (PIN,FREQUENCY,DURATION)

delay (200*d [j]);} //wait until duration period has passed

  delay (2000);


Assuming all went well there, you should have heard a few bars of Mozart's Eine Kleine Nachtmusik. Let's try a siren:


void setup () {




void loop (){


  for (int j=200; j<400;j=j+5){//loop for nl value

    tone (10,j,30); // tone (PIN,FREQUENCY,DURATION)

delay (30);} //wait until duration period has passed




Well, it's a little better but it's not going to be waking up the neighbours any time soon. Let's try feeding the output from the Arduino through an external amplifier and then to the loudspeaker. This can be achieved by using an LM386 IC and just one capacitor.

Arduino input here


The LM386 is a power amplifier capable of knocking out 0.5 W and giving a gain of up to 46 dB on the input signal, which it gets from the Arduino at pin 3. Pin 5 is the output which you can put directly to the speaker but you may get a better effect by coupling through a 220 uF capacitor. C1, between pins 1 and 8 is the capacitor that controls the gain of the chip. A 10 uF gives you 46 dB and leaving open gives you 20 dB of gain.


In this way you can produce some highly audible effects with your Arduino which will come in handy in the project ahead, which is a small alarm system.


Ian Lang, October 2011