Speaker through analog pin

I coded my analog pin 5 with:
analogWrite(A5, 125)

My goal is to sound off a speaker. This is the speaker I used: http://www.jameco.com/1/1/1925-gc0201m-32-speaker-round-32ohm-8-inch-dx-169-inch-h-micro.html

I can’t seem to get the speaker to sound after hooking it up.

I think the PWM pins default to 490Hz and my speaker is rated for 800Hz-7000Hz. I don’t think that’s a major problem though because I connected the speaker and powered it using a function generator that outputted a square wave with a 490Hz frequency and that seemed to work fine.

Do you guys have any suggestions on what I should do and what I did wrong?

Analog pin isn’t PWM. Look on your board, for UNO PWM on digitals outputs # 3, 5,6,9,10 and 11.
And connect resistor in series with speaker, 120 Ohm or so, to prevent damage of microprocessor.

Magician:
Analog pin isn't PWM. Look on your board, for UNO PWM on digitals outputs # 3, 5,6,9,10 and 11.
And connect resistor in series with speaker, 120 Ohm or so, to prevent damage of microprocessor.

Digital pin #3 is free for me.

If I simply use the line:
digitalWrite(3, HIGH);

Does that automatically output PWM 5V?

pyroknife:
Digital pin #3 is free for me.

If I simply use the line:
digitalWrite(3, HIGH);

Does that automatically output PWM 5V?

No, you need to use analogWrite: analogWrite() - Arduino Reference

MichaelMeissner:

pyroknife:
Digital pin #3 is free for me.

If I simply use the line:
digitalWrite(3, HIGH);

Does that automatically output PWM 5V?

No, you need to use analogWrite: analogWrite() - Arduino Reference

Thanks. I tried using:
analogWrite(3, 125);

But it still isn't sounding off the speaker. Do you think this could be a frequency problem? Can you change the PWM frequency?

You may try to play with Tone library:
http://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation

Magician:
You may try to play with Tone library:
http://code.google.com/p/rogue-code/wiki/ToneLibraryDocumentation

Never mind. It works, I just had my circuit wired up wrong. Thanks