Calling tone() without the third duration argument gives the error:
macro "tone" requires 3 arguments, but only 2 given
Program to demonstrate:
void setup() {
tone(8, 262); // NOTE_C4
delay(1000);
noTone(8);
}
void loop() {}
The third argument should be optional:
tone() - Arduino Reference
Tested with Arduino Nano ESP32 core 2.0.11.
1 Like
It is compiled in UNO without any error. It is also compiled in ESP32 Dev Module. I have no NANO ESP32.
Hello @johnsondavies, thanks for spotting this! it will be fixed in the next ESP core release.
If you feel OK with editing core files, you can fix it directly in your own installation: look in your Arduino15 folder for the file [edit: fixed path]
packages/arduino/hardware/esp32/2.0.11/cores/esp32/io_pin_remap.h
(what a mouthful!) and edit the line
#define tone(_pin, frequency, duration) tone(digitalPinToGPIONumber(_pin), frequency, duration)
so it reads
#define tone(_pin, args...) tone(digitalPinToGPIONumber(_pin), args)
@lburelli Thanks, but I don't seem to have io_pin_remap.h. Just io_pin_remap.cpp.
@johnsondavies check at this path:
packages/arduino/hardware/esp32/2.0.11/cores/esp32/io_pin_remap.h
1 Like
My bad, thanks! Edited the post for future reference 
1 Like