But when using the Espressif ESP32 core 3 for the Arduino Nano the LED did not turn off completely.
It had the advantage one could see when the ESP was compiled with Core 3.
But since core 3.3.x I have no problems anymore with the libraries I use but only that faint glowing RGB LED.
The problem is related to changes in the LEDC (LED Control) PWM implementation and how the RGB LED is configured on the Nano ESP32.
To turn off the LED completely.
The value 8191 (maximum for 13-bit PWM) should ensure the LED is completely off in Core 3.x.
//--------------------------------------------
// COMMON Control the RGB LEDs on the Nano ESP32
// Analog range 0 - 512. 0 is LED Off, 512 is max intensity
// 512 is LED off. Therefore the value is subtracted from 512
// In core 3 the value to write is 13-bit 8191 to turn off the led completely
//--------------------------------------------
void SetStatusLED(int Red, int Green, int Blue)
{
analogWrite(LED_RED, Red == 0 ? 8191 : (512 - Red));
analogWrite(LED_GREEN, Green == 0 ? 8191 : (512 - Green));
analogWrite(LED_BLUE, Blue == 0 ? 8191 : (512 - Blue));
}
Ok. I noticed last week I guess where I could digitalWrite the Nano-ESP32's RGB elements - but not after an analogWrite.
I have ezsbc ESP32's with an RBG that won't analogWrite completely Off, but it will go dark with a digitalWrite.
I have difficulties to understand the problem here.
Are you saying that on core 3.3 ledc doesn't give 100% duty with 8191 at 13bit?
What about using ledcWrite?
I probably lost something..
ledcWrite is also possible but more coding.
You have to setup three parameters for the three ledPins (14 ,15 and 16) .
For the Red LED something like this:
int ledChannel = 0;
int freq = 5000;
int resolution = 8;
const int ledPin = 14;
byte red =128;
ledcSetup(ledChannel, freq, resolution);
ledcAttachPin(ledPin, ledChannel);
ledcWrite(ledPin , red)
analogWrite is/was easier and many examples use this method.
But ledc is native esp way to control this peripheral and offers more configurations.
Try to do what ledcFade does with analogwrite...
Most importantly, it works like expected.