Speakers and resistors

I am using a speaker to test my arduino on pin 9 and i was wondering if i need a resistor and if so what will happen if i don't use one.
Thanks,
Ethan

Speaker might be electromagnetic or piezo. Electromagnetic speakers usually have very low resistance and should not be directly connected to Arduino pins. Such a speaker overloads Arduino output pin and might cause miocrocontroller to fail. Piezoelectric speakers behave like a capacitor. You should add a resistor of about 100...470 Ohm in series with piezo speaker.

what resistor should i use with an electromagnetic speaker.

About 82...100 Ohm is a minimum load resistance for microcontroller port pin. If electromagnetic speaker has resistance of, say, 8 Ohm then signal will be significantly attenuated.

so i just shouldn't use an electromagnetic speaker at all?

ComputerNerd:
so i just shouldn't use an electromagnetic speaker at all?

If it's an 8ohm speaker, then it's not a good idea.
Like akouz was saying, in that event, use some additional resistance to pad it up.
Or don't.

so i just shouldn't use an electromagnetic speaker at all?

No. Not without an amplifier. There are lots of audio power amplifier chips if you want to build a small amp, or you can buy a small amplifier (or a BIG amplifier :smiley: ).

The simplest solution is to use regular computer speakers, which have an amplifier built-in and their own power supply. Or, you can plug into your stereo system, etc.

A piezo transducer is essentially a tweeter. You can't get bass or mid frequencies so it's not very good for music or voice, although you can use it for simple music with just high-pitched tones. Those birthday cards that have a sound chip and play Happy Birthday use a piezo.

P.S.
If you have a ~120 Ohm resistor and a speaker, you can put then in series and try it. The Arduino is rated for 40mA maximum, so from Ohm's Law 120 Ohms is the minimum resistance. (With an 8-Ohm speaker, you'd have 128 Ohms total with a little more than 90% of the signal "lost" in the resistor. But, you should still hear something.)

ok, so if i use a tiny speaker, like the size of a dime, i am ok? would i break the arduino or would the sound just not be loud enough if i don't use an amplifier? I'm sorry, i know these are simple questions but I'm not an electrical engineer.

ComputerNerd:
ok, so if i use a tiny speaker, like the size of a dime, i am ok?

No, not if it's a moving coil 8 Ω speaker. The size isn't relevant it's the impedance that's important here.

Something that hasn't been mentioned is that the quoted impedance is the approximate impedance at working frequencies. The resistance (to dc) will be much lower - try measuring it with a multimeter. So if the Arduino is giving a continuous logic 1 output (by accident or design) the situation is even worse.

Russell.

The best solution is to use an impedance matching transformer. Something like 500 ohm primary to the Arduino and 8 ohms secondary to the speaker. This will give you good loud sound. Don't know where to get it. I have a few of them I took out of scrapped transistor portable radios. You might find them at Newark or Mouser or some other Electronics store.

If you want volume, amplify, a transformer won't give any more power that
the Arduino pin can deliver.

And to amplify you might want to consider class-D amplification which only needs
a PWM output in the first place.

No, a transformer will not give you more power, but it will use the power available much more efficiently. Much louder than a speaker with a series resistor, which is almost inaudible.

Arduino can only output 5V x .04A = 200mW absolute max. 100mW is safer long term.

That's 100mW DC, and 50mW with a 50% square wave.
But indeed, a small transformer is the best passive solution.
I would use an electrolytic cap (~100uF) between the Arduino pin and the transformer (+ to Arduino).
2.5volt AC is easier for the transformer and the Arduino than everything superimposed on 2.5volt DC.
Leo..

Okay. Thank you all for your suggestions. I will take them all into consideration!

If you use a transformer to match an 8 Ω speaker to 500 Ω you will need an 8:1 turns ratio and yes use a capacitor in series.

It might be easier to use a cheap amplifier like this.

Russell

I don't need to amplify the sound, just protect the Arduino and the speaker.

Something like an LM386 may be simpler to source than a transformer.

In reading the thread, I did not see any indication of how loud, or if it needs to be high fidelity. So, put about 200 ohms in series, and see if it is loud enough for what you want first.

If it is not loud enough, then maybe look at a high power op amp such as the KA334.