How to avoid initial flashing of common anode RGB LED
Posted: Sun Jan 12, 2020 9:13 pm
Hi
I try to control a common anode RGB LED with ledc functions. My problem is a short initial white flash off the RGB LED on the first boot.
How could I avoid this initial white flash?
Interestingly the initial white flash does not happen after an ESP.restart(); but after it happens after a ESP.deepSleep(2000);
Minimal code:
I already tried to set the pins to HIGH before the call to ledcSetup but this did not remove the short white flash.
I would appreciate any suggestion on how to avoid this initial white flash.
Thanks
I try to control a common anode RGB LED with ledc functions. My problem is a short initial white flash off the RGB LED on the first boot.
How could I avoid this initial white flash?
Interestingly the initial white flash does not happen after an ESP.restart(); but after it happens after a ESP.deepSleep(2000);
Minimal code:
Code: Select all
#include <Arduino.h>
uint8_t ledR = 33;
uint8_t ledG = 32;
uint8_t ledB = 22;
void setup() {
ledcAttachPin(ledR, 1);
ledcAttachPin(ledG, 2);
ledcAttachPin(ledB, 3);
ledcSetup(1, 12000, 8);
ledcSetup(2, 12000, 8);
ledcSetup(3, 12000, 8);
ledcWrite(1, 256);
ledcWrite(2, 256);
ledcWrite(3, 256);
delay(1000);
}
void loop(){
ledcWrite(1, 100);
ledcWrite(2, 100);
ledcWrite(3, 256);
delay(1000);
ledcWrite(1, 50);
ledcWrite(2, 150);
ledcWrite(3, 150);
delay(1000);
ESP.restart();
//ESP.deepSleep(2000);
}
Code: Select all
// ...
digitalWrite(22, HIGH);
digitalWrite(32, HIGH);
digitalWrite(33, HIGH);
ledcAttachPin(ledR, 1);
ledcAttachPin(ledG, 2);
ledcAttachPin(ledB, 3);
ledcSetup(1, 12000, 8);
ledcSetup(2, 12000, 8);
ledcSetup(3, 12000, 8);
// ...
Thanks