This library adds the Arduino tone() and noTone() functions for the ESP32. The library is built that You can use Your existing Arduino code with the ESP32 but also adds some other handy functions.
-
Download, unpack and copy this library into the 'libraries' folder in your Arduino sketchbook folder. If the 'libraries' folder doesn't exist, create a new one.
-
Connect a piezo speaker to pin 15(or any other pin) of Your ESP32 and Ground
-
Open the example sketch Arduino-compatibility-example and upload it to Your ESP32.
This library contains Arduino equivalent functions that You can use with Your ESP32 as they don't work on the ESP32. These are:
tone(int pin, unsigned int frequency)
tone(int pin, unsigned int frequency, unsigned long duration)
noTone(int pin)
They work just as the Arduino functions tone and noTone.
For them to work You have to call setCompatibleMode(true)
or setCompatibleMode()
first (e.g. in setup()).
Otherwise the functions won't do anything!
There is currently one enhanced function:
beepForever(int pin, unsigned int frequency, unsigned long toneOnTime, unsigned long toneOggTime, unsigned int repeatTone, unsigned long toneDelay)