Hi,
I am trying out a YL-44 active buzzer on my Arduino Nano board. The wiring is dead simple, as specified in numerous online tutorials: VCC to 5V, GND to GND, I/O to D3 (PWM pin).
The code is dead simple as well:
int buzzerPin = 3;
void setup() {
pinMode(buzzerPin, OUTPUT);
analogWrite(buzzerPin, 50);
delay(100);
analogWrite(buzzerPin, 0);
}
void loop() {
}
But when I run this code, I hear a "click" sound, and my Arduino resets. Buzzer doesn't make any sound. After a few seconds it reboots, makes a click, and resets again. I tried commenting out the analogWrite calls in my code - doesn't change anything. Only if I comment out the pinMode, it stops resetting (but neither makes any sound, of course).
I tried another YL-44, as well as another Arduino Nano. I power it from my PC via USB cable, but I also tried powering it from a power bank, same deal. I also tried placing a resistor between the I/O pin on the YL-44 and the D3 on Arduino, suspecting that there's some kind of short-out, but it didn't help.
Why could this be happening?
VCC to 5V,
What?
If you have an active buzzer you only need set the output high or low to make a sound. A passive buzzer needs a signal like from the tone function.
What happens when you connect your buzzer direct to 5V and ground?
It sounds like the buzzer is drawing too much current or is generating interference.
Can you post a link to the buzzer.
Thank you for your reply. Oh damn. It's a passive buzzer. I'm sorry, my mistake. I can't find a datasheet for it, but here is a picture of it: https://techtutorialsx.files.wordpress.com/2016/05/yl-44-passive-buzzer-module.jpg?w=208&h=208
If I connect the buzzer direct to 5V, the Arduino doesn't crash, but there is no sound either.
As I said, I tried limiting the current using a resistor, but it didn't seem to help...
If I connect the buzzer direct to 5V, the Arduino doesn't crash, but there is no sound either.
Not even a click?
Maybe it is broken?
This link:- Active Buzzer Alarm Type YL-44 – Rydepier Blog Spot top return on googling the part number says it is active and you should get a tone out of connecting it directly to 5V and ground. So if you don't get a sound it is broken, or you are not making the connections correctly.
Grumpy_Mike:
Not even a click?
Maybe it is broken?
This link:- Active Buzzer Alarm Type YL-44 – Rydepier Blog Spot top return on googling the part number says it is active and you should get a tone out of connecting it directly to 5V and ground. So if you don't get a sound it is broken, or you are not making the connections correctly.
No, not even a click... I tried two separate buzzer modules, and neither of them made a click sound. There's just nothing.
The schematic in that link involves a transistor acting as a switch... I guess that means that the buzzer takes more current than Arduino can supply, hence the reset.
When I said connecting directly to 5V and ground you should also connect the input to ground because if the transistor.
While the resopistor looks low in value I would not expect it to draw more than the Arduino could cope with. Have you tried the code in that link I posted?