Compilation error: 'ledcSetup' was not declared in this scope
tried to point you to the Espressif documents that explain what are the differences between version 2.x and 3.x of the ESP32 API.
On 3.x version, ledcSetup()
and ledcAttachPin()
are no longer available. That means you have 2 options:
Rollback the version of the ESP32 board to the version 2.x OR modify your code according to the new API. Since the code is nor big or complex, I suggest the second option.
void setup() {
ledcAttach(LEDC_PIN, 50, LEDC_RESOLUTION);
}
and all ledcWrite functions thereafter will need to be:
ledcWrite(LEDC_PIN, dutyCycle);
LEDC
The LEDC API has been changed in order to support the Peripheral Manager and make it easier to use, as LEDC channels are now automatically assigned to pins. For more information about the new API, check LED Control (LEDC).
Removed APIs
ledcSetup
ledcAttachPin
New APIs
ledcAttach
used to set up the LEDC pin (mergedledcSetup
andledcAttachPin
functions).ledcOutputInvert
used to attach the interrupt to a timer using arguments.ledcFade
used to set up and start a fade on a given LEDC pin.ledcFadeWithInterrupt
used to set up and start a fade on a given LEDC pin with an interrupt.ledcFadeWithInterruptArg
used to set up and start a fade on a given LEDC pin with an interrupt using arguments.
Changes in APIs
ledcDetachPin
renamed toledcDetach
.- In all functions, input parameter
channel
has been changed topin
.