Active Buzzer Alarm Type YL-44

  

Buzzers come in two varieties, Active and Passive. An active buzzer just outputs a single tone when you connect it to Vcc and ground.   A passive buzzer is similar to a loudspeaker and needs a signal to make it work.

The YL-44 is a small buzzer module which operates around the audible 2 kHz frequency range. It is an active buzzer, which means that it produces sound by itself, without needing an external frequency generator. Taking the I/O pin LOW will turn the buzzer ON and taking this pin HIGH will turn the buzzer OFF (as will leaving this pin OPEN). This device could be controlled by PWM.

 

 This code will produce a two tone output

/*Example Code for YL-44 Active buzzer
Connect Vcc to 5 volts
Connect Gnd to Gnd
Connect I/O to pin 3


int buzzer = 3 ;// connect the I/O pin on the buzzer to this


void setup ()
{
pinMode (buzzer, OUTPUT) ;
}
void loop ()
{
unsigned char i, j ;// define variables
while (1)
{
for (i = 0; i <80; i++)
{
digitalWrite (buzzer, LOW) ; // Turn buzzer ON
delay (1) ;// Delay 1ms
digitalWrite (buzzer, HIGH) ;// turn buzzer OFF
delay (1) ;// delay ms
}
for (i = 0; i <100; i++) // new frequency
{
digitalWrite (buzzer, LOW) ;// turn buzzer ON
delay (2) ;// delay 2ms
digitalWrite (buzzer, HIGH) ;// turn buzzer OFF
delay (2) ;// delay 2ms
}
}
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s