Hi,
In my project i want to be able to use a passive buzzer using the digitalWrite command. However im getting a little confused how i can actually control the buzzer how i want it. I simply just want the buzzer to beep on and off with around a half a second delay on it. i have created one small program that does this however it isnt the best. So if anyone has any advice or pointers to where to go next it would be appreciated
Here is the code:
while(1)
{
for(int i = 0; i <200; i++)
{
digitalWrite(buzzPin,HIGH);
delay(1);
digitalWrite(buzzPin,LOW);
delay(1);
}
digitalWrite(buzzPin,LOW);
delay(500);
}
This does not work on passive buzzers. It will just make a small noise. For a passive buzzer your delay inbetween has to be extremely short for it to work.
For a passive buzzer to create a sound, you will have to send a rapid series of on and off pulses for it to generate a tone. This is because a passive buzzer does not have a built in Oscillator.
I have confused passive and active buzzers in my replies and you are quite right in saying that a passive buzzer needs a series of short HIGH/LOW in order to make a sensible noise