Please post your sketch, using code tags when you do. This prevents parts of it being interpreted as HTML coding and makes it easier to copy for examination
In my experience the easiest way to tidy up the code and add the code tags is as follows
Start by tidying up your code by using Tools/Auto Format in the IDE to make it easier to read. Then use Edit/Copy for Forum and paste what was copied in a new reply. Code tags will have been added to the code to make it easy to read in the forum thus making it easier to provide help.
I forgot to mention that this is a new installation of arduino IDE 2.3, I already installed the esp32 espresif. So I need to install other libraries?¡
#include <Arduino.h>
#include <esp32-hal-ledc.h>
// Define LEDC channel, GPIO pin, and resolution
#define LEDC_CHANNEL 0
#define LEDC_PIN 12
#define LEDC_RESOLUTION 10 // Set resolution to 10 bits
void setup() {
// Initialize LEDC channel
ledcSetup(LEDC_CHANNEL, 50, LEDC_RESOLUTION); // Set frequency to 50Hz, resolution to 10 bits
ledcAttachPin(LEDC_PIN, LEDC_CHANNEL); // Associate GPIO pin with LEDC channel
}
void loop() {
int dutyCycle = (pow(2, LEDC_RESOLUTION) - 1) * 0.075; // Calculate duty cycle value using 10-bit resolution
ledcWrite(LEDC_CHANNEL, dutyCycle);
// Delay for 1 second
delay(1000);
dutyCycle = (pow(2, LEDC_RESOLUTION) - 1) * 0.0875; // Calculate duty cycle value using 10-bit resolution
ledcWrite(LEDC_CHANNEL, dutyCycle);
delay(1000);
dutyCycle = (pow(2, LEDC_RESOLUTION) - 1) * 0.075; // Calculate duty cycle value using 10-bit resolution
ledcWrite(LEDC_CHANNEL, dutyCycle);
delay(1000);
dutyCycle = (pow(2, LEDC_RESOLUTION) - 1) * 0.0625; // Calculate duty cycle value using 10-bit resolution
ledcWrite(LEDC_CHANNEL, dutyCycle);
delay(1000);
}
the error output
/home/gaston/Arduino/sketch_sep16b/sketch_sep16b.ino:9:5: error: 'ledcSetup' was not declared in this scope
9 | ledcSetup(LEDC_CHANNEL, 50, LEDC_RESOLUTION); // Set frequency to 50Hz, resolution to 10 bits
| ^~~~~~~~~
/home/gaston/Arduino/sketch_sep16b/sketch_sep16b.ino:10:5: error: 'ledcAttachPin' was not declared in this scope; did you mean 'ledcAttach'?
10 | ledcAttachPin(LEDC_PIN, LEDC_CHANNEL); // Associate GPIO pin with LEDC channel
| ^~~~~~~~~~~~~
| ledcAttach
exit status 1
Compilation error: 'ledcSetup' was not declared in this scope
@ZX80 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.