I have a YL-44/MH-FMD passive piezo buzzer hooked up to an ESP8266/NodeMCU.
It's connected like this: Buzzer ---> NodeMCU
- GND ---> G
- VCC ---> 3V
- I/O ---> D2
This code makes a clear beep.
void loop() {
analogWrite(BUZZER, 255);
delay(100);
analogWrite(BUZZER, 0);
}
This code makes a weird low clicking sound, no beep.
void loop() {
digitalWrite(BUZZER, HIGH);
delay(100);
digitalWrite(BUZZER, LOW);
}
I have no idea why the second one doesn't work, as all the tutorials reference that one.
Also, why does the buzzer have a weird constant static noise and gets hot?
Am I doing something wrong in the wiring? I use no resistors, as the tutorials don't show that.