Open jomoengineer opened 1 week ago
Thanks for the report. I need to go back and review code for the EEK with the 3.0.x ESP32 Core that is out now. Here are two little examples that I need to adapt my code towards:
int led = 12; // the PWM pin the LED is attached to
int brightness = 0; // how bright you want the LED to be
int fadeAmount = 5; // how many points to fade the LED by
// the setup routine runs once when you press reset:
void setup() {
// declare pin 12 to be an output:
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
// set the brightness of pin 12:
analogWrite(led, brightness);
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
And
const byte led_gpio = 12; // the PWM pin the LED is attached to
int brightness = 0; // how bright the LED is
int fadeAmount = 5; // how many points to fade the LED by
// the setup routine runs once when you press reset:
void setup() {
// Initialize Pin for ledc based PWM
ledcAttach(led_gpio, 4000, 8); // 12 kHz PWM frequency, 8-bit resolution
}
// the loop routine runs over and over again forever:
void loop() {
ledcWrite(led_gpio, brightness); // set the brightness of the LED
// change the brightness for next time through the loop:
brightness = brightness + fadeAmount;
// reverse the direction of the fading at the ends of the fade:
if (brightness <= 0 || brightness >= 255) {
fadeAmount = -fadeAmount;
}
// wait for 30 milliseconds to see the dimming effect
delay(30);
}
Good old analogWrite
now works.
Channel concerns are no longer front and center.
I tried running the code list under Section5PWM and I get the error listed below. After some searching, I found there has been some changes in the ESP32 Board library in the 3.x versions where ledcSetup and ledcAttachPin have been removed and replaced with just ledcAttach.
Ref: https://docs.espressif.com/projects/arduino-esp32/en/latest/migration_guides/2.x_to_3.0.html
There is a LEDCFade example in the Arduino Examples for the ESP32 that has the changes in it.
This is the error that I seen.