0

I bought a 3 pin buzzer. It has positive, negative and signal pin.

I don't understand how this signal pin should be connected with the Arduino.

Here is reported the description page of the buzzer.

2 Answers 2

1

As I have read in the page you have linked, I think you should program the Arduino to provide an impulse to the signal (s) pin.

Therefore, to answer your question you can use any digital pin of the Arduino. And I guess that as long as the impulse last as long as the buzzer will produce a sound.

Here an example of code:

int buzzPin =  2;    //Connect Buzzer on Digital Pin3 
void setup()   
{         
 pinMode(buzzPin, OUTPUT);      
} 
 void loop()                      
{ 
 digitalWrite(buzzPin, HIGH); 
 delayMicroseconds(50); 
 digitalWrite(buzzPin, LOW);  
 delayMicroseconds(50);    
}
1

Usually a buzzer only has two wires, positive and negative. The module you have bought though uses a transistor to drive the buzzer, which is a nice thing for very low power boards, which is not your case I believe.

Anyway, the module will take power from the positive and negative connections, allowing you to control it via the signal, from which very little power is drained.

How does a buzzer work? Actually to emit a sound via a buzzer you have to send a series of electrical pulses to the signal pin. The number of pulses per second (frequency, expressed in hertz, Hz) will determine the tone of the sound. higher the frequency, higher the pitch of the sound emitted.

Human ear is capable to detect frequencies between 20 and 20000Hz, but not everybody has such a broad perception, it decreases with age and not everybody is born with full range, so I advice to stay in the 2000-15000Hz range.

There is a nice library called Tone which helps you generate the correct signal for specific notes, allowing to even play some music via the buzzer (don't expect polyphony though!)

So, to play a note on your buzzer, assuming you have the buzzer signal pin tied to digital pin 6, you can just:

void setup() { /* empty */ }

void loop() {
    noTone(6);
    // play a note on pin 6 for 200 ms:
    tone(6, 440, 200);
    delay(200);
}

Also have a look at ToneMelody if you wish to emit specific notes (each note has its own particular frequency)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.