Active Buzzer Alarm Type YL-44 - Rydepier Blog Spot

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 } } }

Share this:

  • X
  • Facebook
Like Loading...

Related

Tag » Arduino Yl-44