Currently have a generic HF-12095 peizo buzzer wired up to the XIAO RP2040. The positive terminal of the buzzer is connected to USB, so 5V+. The negative terminal on the buzzer is being switched from a transistor, which is driven by D5 (GPIO7 on the chip). Note: Removing the transistor from my setup and wiring the buzzer directly to the XIAO doesn’t fix my issue.
The simplest code I have used to test this would be as follows:
void setup(){
pinMode(7, digitalOutput);
digitalWrite(7, LOW);
}
void loop(){
tone( 7, 1000);
delay(1000);
noTone(7);
delay(1000);
}
Everytime the buzzer will correctly function for 6 loops, then it will cease to function. I have tested to make sure the loop is still running by initiating the Neopixel in setup then cycling it ON/OFF in the loop, same as the buzzer. The neopixel continues to function.
Oddly, the included tone examples in the Seeed RP2040 boards package also cease to function after say 5-10 seconds. I don’t know if this is a timing issue or what, but any help would be appreciated.
Open the Board Manager and set the version of “Seeed XIAO RP2040” to 1.12.0.
Okay, I will be able to test this later today. I checked and I am currently running 1.9.3 for my board version. Was this a known issue? Or at least, what is the reasoning behind reverting to an older version to fix this timing issue. More curious than anything.
I have two PCs.
As it happens, one was version 1.9.3 and the other was 1.12.0.
Isn’t the HF-12095 an active buzzer with an oscillator circuit inside? If so, it is driven by “digitalWrite()” instead of “tone()” and the pitch of the sound cannot be changed.
If you want to use “tone()” to change the pitch, you need to use a passive buzzer.
You are correct; the HF-12095 is an active buzzer. I should have clarified that I am not using that specific buzzer, merely something of the same generic form factor. I am using a passive buzzer.
I finally had the chance to test the code with package version 1.12.0, and it works as intended. The only change was downgraded the version from 1.9.3 and the buzzer worked as it should.
Can we infer that there is an error in board package version 1.9.3?