connecting arduino to a speaker

I played with leds and now I want to try a speaker, what I wan't to know is it safe to connect a speaker (taken from a home theater system) to one of the pins without a resistor or something?

No - do not do this. You can connect a small piezo speaker directly, but nothing of any larger size.

You should only connect such speakers through an amplifier, the amplifier input would be driven by the Arduino (thru an inline capacitor, usually). A simple basic amplifier IC would be the LM386:

http://www.national.com/mpf/LM/LM386.html

Classic, its been used everywhere; plenty of reference material on it, though the reference design inside the spec sheet will work fine to drive your speaker.

Something to keep in mind is that the output from the Arduino will be a wave (square, if using a single pin) with a voltage swing from 0-5 volts. While you can feed this into an amplifier, its not really correct; you really want a swing around 0V, and attenuated somewhat to reduce it to about 1 or 2 volts peak-to-peak (vpp). To do this, you need to bias the output signal so that ground is about 2.5 volts higher than normal, so-as to pull the signal down and center it. Then, you use a small trimmer potentiometer to reduce the signal (via a voltage divider).

Note - if this all sounds like "greek" to you, stick with something pre-built, or a piezo, or do a lot of research and learning...

:slight_smile: