Thomascountz / thomascountz

Personal Site
https://thomascountz.com
MIT License
0 stars 0 forks source link

2021/02/21/arduino-tone-for-esp32 #3

Open utterances-bot opened 3 years ago

utterances-bot commented 3 years ago

Arduino Tone for ESP32 - Thomas Countz

Arduino has a built-in tone() library which allows you to send a PWM frequency at 50% duty cycle to a specific pin in order to generate a tone on a piezoelectric buzzer with an optional duration.

https://thomascountz.com/2021/02/21/arduino-tone-for-esp32

jcernato commented 3 years ago

Unable to change frequency! My buzzer beeps for the given duration but the frequency is unchanged (~2KHz - just guessing) no matter what I specify. I'm working with platformIO in the arduino framework (which is probably the root cause of the problem) buzzer pin is 25, only channels 0 and 1 are working. Any ideas?

jcernato commented 3 years ago

Woha I feel really stupid now. I was not aware that the buzzer I have generates the oscillating signal itself. The buzzer works well at the 50% duty cycle though...

Thomascountz commented 2 years ago

@jcernato I had that issue too. Piezo buzzers come in two configurations: passive and active.

An active buzzer generates the sound itself. You basically just turn it on or off. A passive buzzer needs a signal source that provides the sound signal. —https://stackoverflow.com/questions/41578741/how-to-differentiate-active-and-passive-buzzers-in-arduino

taffarel55 commented 2 years ago

cool :heart:

jberezin commented 11 months ago

You can now use the normal tone() with esp32 as it is built in (at least as of August 2023).