Introduction: Arduino YL-44 Buzzer Module

Welcome to this tutorial!

So about a time ago I sat and looked around at my favorite site for ordering all kinds of arduino sensors, boards and much more. You might already have guessed it, but I am of course speaking about www.aliexpress.com. I just was looking and an actuator got my eyes. It was a buzzer module which was great for a future project. You can for example make it buzz every time you start your program. Although once I got it home, I was not really prepared for how to deal with this new unit. This might sound kind of stupid, but I am just a newbie to arduino. Got my genuine ardunio UNO for about a month or two ago, so bare with me.

After searching google, contacting seller and searched on google again, I did not find a solution. Then finally the seller provided me with what I needed, a square wave.

Now, I am going to show you how to connect this module and speak with it, sorry, make it understand my crappy code.

Step 1: Parts

Start by getting the required parts:

YL-44 buzzer (1$)

Any arduino board really (3-15$ depending on which one you get)

A couple of jumper wires (2-3$)

Step 2: Connections

Notice that I am using the arduino MEGA, but you can use any board you would like, for example, this code works on both the UNO and the Nano.

Your connections should be like the pictures and as following:

VCC -> Arduino 5V

I/O -> Any arduino PWM pin (I used 3)

GND -> Arduino GND

Step 3: Your Code

Now your code is easy as ABC, although we will create our own fast function to interact more easily.

This code worked great for me without any errors, enjoy!

Refer to Comments for explanation

//Code written by Samuel.

int buzzerPin = 3; //Define buzzerPin

void setup() { pinMode(buzzerPin, OUTPUT); //Set buzzerPin as output beep(50); //Beep beep(50); //Beep delay(1000); //Add a little delay

}

void loop() { beep(50); //Beep every 500 milliseconds delay(500); }

void beep(unsigned char delayms) { //creating function analogWrite(buzzerPin, 20); //Setting pin to high delay(delayms); //Delaying analogWrite(buzzerPin ,0); //Setting pin to LOW delay(delayms); //Delaying }

Step 4: Finished

Now I hope this helped you, and that your YL-44 is working now. Thanks for reading and as always, please favorite and subscribe for more tutorials.

Samuel

Comments

author
snoop911 made it!(author)2017-06-17

I'm looking for a buzzer than can be turned on when the control signal is high...

On ebay I found a buzzer that says 'High Level Trigger for Arduino', I assume this to mean when the control signal is HIGH, the buzzer will sound, right?

However, if it has a pnp (2TY) transistor shouldn't the base control signal be LOW for the buzzer to sound? Only if it had an npn (ex. 2N2222) transistor THEN the base control signal is HIGH for the buzzer to sound.

Also is it possible for the VCC and the control signal to be 12V instead of 5V? Or would the buzzer and/or limiting current resistor have to change?

author
KjartanA made it!(author)2015-10-10

If you have a unit that need digital input to work (as my YL-44). You could try this code for some fun:

/* Buzzer type YL-44 with VCC, GND and I/O pin
* YL-44 will have sound ON when I/O is LOW
* Written by Kjartan, LA6SRA, 2015
*/

int buzzPin= 12; // I/O-pin from buzzer connects here
const int wpm = 20; // Morse speed in WPM
const int dotL = 1200/wpm; // Calculated dot-length
const int dashL = 3*dotL; // Dash = 3 x dot
const int sPause = dotL; // Symbol pause = 1 dot
const int lPause = dashL; // Letter pause = 3 dots
const int wPause = 7*dotL; // Word pause = 7 dots

void setup()
{
pinMode(buzzPin,OUTPUT); // Set buzzer-pin as output
}
void loop()
{
dash();
dot();
dash();
dot();
delay(lPause-sPause); // Subtracts pause already taken

dash();
dash();
dot();
dash();
delay(wPause-sPause); // Subtracts pause already taken

}

void dot(){
digitalWrite(buzzPin, LOW); // Tone ON
delay(dotL); // Tone length
digitalWrite(buzzPin, HIGH); // Tone OFF
delay(sPause); // Symbol pause
return;
}

void dash(){
digitalWrite(buzzPin, LOW); // Tone ON
delay(dashL); // Tone length
digitalWrite(buzzPin, HIGH); // Tone OFF
delay(sPause); // Symbol pause
return;
}

author
VeliP made it!(author)2017-02-10

Thank you so much! Had really bad problems with constant buzzing until found your code. Now my buzzer starts to morse "Fridge Open" if someone leaves the door open :p.

author
amichaud64 made it!(author)2015-08-11

I did the same configuration.

Get a very loud noise and a beep at the frequence you indicate.

Do you know why I am getting the noise ?

author
KjartanA made it!(author)2015-10-10

YL-44 is not intended to be used with a PWM-pin. Instead you set the I/O-pin LOW to get the buzzer going. And HIGH to make it stop buzzing. If you use PWM there will be a constant buzzing from the unit and just small changes when the PWM changes.

There may be different types of the unit out there. At least this tutorial would indicate that.

author
g_dynamics made it!(author)2016-06-25

+1

My 3 PIN buzzer does not work in PWM mode, works only as KjartanA says.

About This Instructable

19,089views

9favorites

License:

Bio: Hello, My name is Samuel, I am a student. I love micro controllers like arduino, they are my favorite interest. I also do geocaching, a ... More »
More by samuel123abc:Real time clock using DS3231 (EASY)Controlling 120-240 VAC with a relay using arduinoNokia 5110 graphics tutorial
Add instructable to: