PC speaker

Hello,

I've found a small speaker (I think the one that does beep on your PC :slight_smile: ) the diameter is 1 cm. On the side stands : THDZ, I think thats the brand of the speaker but can't find anything about is.

Here is a image:

How can it be controlled using arduino? and a what voltage?

Thanks in advance.

I've used a simple buzzer with my Arduino quite a lot. I'm currently working on wave generation with variable frequency, but that probably wouldn't work with this speaker anyways. Anyhow, I'd guess this speaker operates at 5V, so that works nicely with the Arduino. As far as wiring goes, just stick the black wire into GND and pick your favorite digital pin for the red wire. Here's some sample code once you've got that done:

#define SPKR 13 //this is the digital pin that you plugged the red       wire into

void setup()
{
    pinMode(SPKR, OUTPUT); //set the speaker as output
}

void loop() //do this over and over
{
    digitalWrite(SPKR, HIGH); //turn the speaker on
    delay(500);                     //wait for half a second
    digitalWrite(SPKR, LOW); //turn the speaker off
    delay(500);                    //wait for half a second
}

Good Luck!

The PC speakers are usually not "buzzers." You probably have to give them an actual audio signal.
Physically, such speakers are usually pretty current-hungry devices. You should probably connect a 100 ohm (approximately) resistor in series with the speaker and whatever IO you connect it to:

digitalPin---Resistor---Speaker---GND

This cuts down on the available volume, but is OK for experiments. You can use a simple one-transistor amp for higher volume.)

(Pretty much just like an LED, with the "amp" being like the circuit for a high-power LED.)

There is some material in the playground: http://www.arduino.cc/playground/Main/InterfacingWithHardware#audio_tutorial but it seems to be a bit software-oriented.

That PC device looks like a piezo speaker. You can drive it directly from an Arduino digital output pin.

I have been using this for a long time. Simply connect the - to the ground and + to one of the PWM pins. With digitalWrite it doesn't work that good. But with analogWrite it beeps quite good.