Using a piezzo buzzer

I've done some reading around the forum, from what I gather, I can just run the positive lead of the buzzer to a digital pin on the arudino mega. And the GND to GND.

My only question is do I need a resistor between the digital pin and the buzzer.

http://www.soberton.com/NewFiles/Product%20PDFs/ST-04CH.pdf

I'm only going to be running at the one frequency 2.73Khz

Coil Resistance (?) 30±3

I don't think piezo buzzers have a coil.

Current Consumption (mA) MAX.70

You need to include a current limiting resistor. Try to keep the current around 20 mA.

Would that buzzer still work even though its not a piezoelectric buzzer ?

Ok so R = 5V / 0.02A so 250 Ohms.

Would that buzzer still work even though its not a piezoelectric buzzer ?

Should. Things with a coil really should have a diode across the terminals. Consider a typical circuit for driving a solenoid...

http://www.arduino.cc/playground/uploads/Learning/solenoid_driver.pdf

Diode D1 is there to protect the rest of the circuit when the magnetic field in L1 collapses.

To protect your Arduino, you should start with a diode across the buzzer; like D1 is to L1 in that circuit. At the voltage and current of the buzzer, I suspect nearly any diode will work.

Ok so R = 5V / 0.02A so 250 Ohms.

That is a great place to start.

I see what you mean by the diode. So I might as well put a 1k resistor in place then to limit the current and use a diode to make sure nothing in the circuit gets damaged.

My math im not sure is correct 1k or the 250 Ohm?

Your math is fine...
5 V / 0.020 A = 250 ohms

The device has a resistance of about 30 ohms so you can use a resistor down to 220 ohms. A bigger resistor is going to reduce the volume.

Ok so I have hooked up the buzzer and nothing :frowning:

pin 12 -> 220 Ohm -> buzzer -> GND

I've tried the Tone library

tone(12, 2730);

and I tried

for (long i = 0; i < 2048 * 3; i++ )
{
// 1 / 2048Hz = 488uS, or 244uS high and 244uS low to create 50% duty cycle
digitalWrite(buzzPin, HIGH);
delayMicroseconds(244);
digitalWrite(buzzPin, LOW);
delayMicroseconds(244);
}

But neither works. I must be missing something?

As far as I can tell, this is the only hint from the datasheet on how to use the device...

*applied voltage: Rated Voltage, 1/2 duty, square wave

Either tone or your snippet should do the trick.

Which leaves...

  1. Wired backwards (it has positive and negative terminals)

  2. Resistor too big / not enough current flowing (bear in mind that if you exceed 40ma you will damage the processor)

  3. Broken / defective

  4. Gross conceptual error (it appears to be a buzzer when in fact it is something completely different)