Connecting an 8 ohm speaker to Arduino

I'm a complete beginner to electronics, and recently bought a Make kit from MakerShed. I got through the lessons in "Getting Started with Arduino" book, but then broke out on my own by trying a simple sketch I found on Arduino.cc (see full link below).
The problem is I didn't know how to use extra wiring to connect these super small red and black wires that come with the 8 ohm speaker to the Arduino Uno. The wires are very small. So I stuck them in directly to the Arduino Board in Pin 8 (red) and Grd (black), and the program played the melody as stated after I compiled and uploaded it to the board. So far so good?

The program is at http://arduino.cc/en/Tutorial/tone

While it did play the melody, I didn't use the resistor, and didn't know how to connect connecting wires to the small wires instead just painstakingly put the teeny tiny wires of the Speaker into the 8 pin and grd. It was a super pain in the a--. Is there better/correct way to connect the wires to play the melody?

After the above "success" in that at least the program ran, I tried improving the connection and so tried tying a couple of jumper cables around the super small red and black wires, but in the process broke the speaker wires off of the speaker, and so after I buy a new 8 ohm speaker, can someone tell me how to correctly deal with the connection from Speaker to Arduino and what kind of connecting cables I need, and how to connect these teeny tiny red and black wires?

Thanks for your help,

Confused :roll_eyes:

If you connected the speaker directly to the arduino like you said you have damaged your arduino pin by pulling too much current from it. It might still work for now but it is damages.
You need at least a 120R resistor in line with the speaker for direct connection. Ofcourse it will not be as loud but then you are not rapeing your output pin.
For best results you need to use a transistor and capacitor to connect your speaker. Google for lots of schematics.

To drive an 8? speaker you really need a power amplifier.

The simplest form is a transistor with base bias resistors and a capacitor to decouple the DC offset of the Arduino's signal.

Digital components with low current capability shouldn't be directly driving reactive loads unless very high series resistances are present. Even through a 120 ohm resistor, the kickback can develop a very high voltage across an output pin, and it's of the wrong polarity. It causes a current to flow between the substrate and n-doped well in any PMOS devices present on the chip (if any, I haven't seen atmel's schematic for it's mega series). This can crash the processor, cause memory errors, and may even damage the chip.

Use diode protection, and a drive transistor if you can.

I would strongly recommend you get some lm328 chips if you are interested in speaker and audio projects, it a low cost amplifier on a chip. If you search around youtube you will find, ipod amplifiers, guitar amplifier etc etc all built using this great little chip.

I have one on an Audino Arduino based synthesisor, I simply copied the minimal circuit from the lm328 datasheet and use it to drive a pc speaker from the Arduino, its a great chip so but three or four.

You could also get some lm3916 chips and add a vu meter to your projects. they are both incredibly simple chips to use.

Duane B

rcarduino.blogspot.com

First try the 120 ohm resistor as Mike suggested, see (a) in the image. If that isn't loud enough, try the simple amplifier shown in (b). If that's too loud, connect a resistor in series with the speaker.

If you're in the USA, RadioShack still has available an "audio output transformer".

You still need a transistor, wire the primary/high-impedance side (its leads) as the load in Common Emitter circuit and connect the low impedance leads to your 8? speaker.
I think it does a pretty good job that way.

They do have fine, stranded leads which aren't directly compatible with the breadboard. Perhaps you can do some spot soldering to make some solid wire transitions or make some strip'em-and-twist'em pig-tails, as necessary.

I could make a case for direct Arduino output to it, too (adding a smallish resistor in series with the primary) - and probably the old flyback diode (because it's a coil still.)