Closed Virtronics closed 4 years ago
Hi there! Thanks for trying out the library.
I haven't ever used it with a piezo buzzer, so I'm not entirely sure what's going on, but I'd guess the issue is that for speakers you want to use tone(), but for a piezo buzzer you want to use just digitalWrite HIGH/LOW, like an LED. If you used pin 3, that's what I'm using for PIN_SPEAKER in the examples, so you're probably getting the square wave output of tone() into the piezo buzzer.
In speeds.ino, try replacing SpeakerMorseSender with LEDMorseSender (so both senders are LEDMorseSender), and I think that will produce nicer output for a piezo buzzer.
Hi Mark
Thanks for the reply. I am using a piezo buzzer which needs to be driven by an AC or pwm waveform.
With the concurrent sketch, the first loop through sounds terrible with background noise and beeps but then it clears to beeps only and sounds good.
With the speeds.ino sketch, there is background noise always when the piezo buzzer is not beeping.
The piezo buzzer is like a speaker but only uses 20mA of current. Thanks
On Tuesday, January 17, 2017, Mark Fickett notifications@github.com wrote:
Hi there! Thanks for trying out the library.
I haven't ever used it with a piezo buzzer, so I'm not entirely sure what's going on, but I'd guess the issue is that for speakers you want to use tone(), but for a piezo buzzer you want to use just digitalWrite HIGH/LOW, like an LED. If you used pin 3, that's what I'm using for PIN_SPEAKER in the examples, so you're probably getting the square wave output of tone() into the piezo buzzer.
In speeds.ino, try replacing SpeakerMorseSender with LEDMorseSender (so both senders are LEDMorseSender), and I think that will produce nicer output for a piezo buzzer.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/markfickett/arduinomorse/issues/6#issuecomment-273010289, or mute the thread https://github.com/notifications/unsubscribe-auth/ASlCrtEVnJFsD-FqQ24GigOTRS8wc1-_ks5rTC7ogaJpZM4LkKgt .
I tried this out today. You can set the carrier frequency to CARRIER_FREQUENCY_NONE when calling the SpeakerMorseSender constructor. That removed the noise when I was using a piezo buzzer.
Hope this helps!
Glad you found a workaround. Let me know / feel free to send a PR if there are particular doc updates that would make it easier to figure that out (or if there are default values that could be different to make the behavior ideal without breaking existing usage).
Hi, I just downloaded the library and tested the Concurrent.ino sketch and the speeds.ino example. I connected a piezo beeper to pin3.
The concurrent sketch plays the tune and flashes the light but there is some background buzzing. On the second run through, the beeper is fine.
With the speeds example, the background buzzing is always present. Not sure if the background buzzing is intentional but it sounds terrible.