I'm trying to power an active piezo buzzer with a digital pin. But it wont make a sound, just a small click when it changes from high or low.
But if it connect the buzzer from GND straight to +3.3V pin, it do make a high pitch sound. When i set a pin to high, they also provide 3.3V but the buzzer don't want to make a sound then.
What am I doing wrong? This works on my UNO.
void setup() {
pinMode(2, OUTPUT); // sets the digital pin 13 as output
}
void loop() {
digitalWrite(2, HIGH); // sets the digital pin 13 on
delay(1000); // waits for a second
digitalWrite(2, LOW); // sets the digital pin 13 off
delay(1000); // waits for a second
}
I've also tried using tone(); but it wont make as high a sound.
Does the plastic case have a "+" molded into case? If so, are you connecting that pin to the Arduino control pin and the other piezo pin to the Arduino ground?
The pins of an Uno can source up to 40mA before they become damaged. (That should be kept to 20~30mA for long life).
The pins of a Nano 33 BLE cannot provide as much current, only 10mA before they become damaged. That is probably not enough to operate your sounder. You may have already damaged the Nano by connecting it.
You probably need to use a transistor to provide the current for the sounder, so the Nano pin only needs to provide a small current to operate the transistor.
The active buzzer may require more current than the Arduino can supply. (The I/O pins are rated for 40mA "absolute maximum".)
Usually a passive piezo will work but an active buzzer needs "power" to drive it's internal tone generator.
If you don't have the specs and if you do have a multimeter, write a high with nothing but the meter connected and you should get around 5V. Then connect the buzzer to see if the voltage holds-up. It will probably drop a little but it shouldn't drop to 3.3V or less.
Or if you don't have a meter, try pin 13 and if the built-in LED dims when you connect the buzzer, that's the problem.
You probably need to use a transistor to provide the current for the sounder, so the Nano pin only needs to provide a small current to operate the transistor.
You are most likely right. Thank you, I'm really shit a the electrical points of things, but I'm trying to learn.
Will try this out!
Luckily enough i had some transistors in my old start up kit. Just have never used them or known what they were for. You learn something new every day
Now i can finally finish my project.
Then you really should post a schematic showing how you connected the transistor, Nano and sounder, in case you are still damaging to the Nano's pin, even though the sounder is working now. Don't forget to include the model of transistor you are using.
The "middle foot", the base, of an N-P-N must be connected to the Arduino pin using a resistor. Without the resistor, too much current will flow and the Arduino pin will be damaged. Resistor should be at least 330R.