Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By snafu
#55619 In my setup[1] I have lots of flicker on my PWM outputs driving LEDs. If I use only two channels, everything is fine. If I add one or more channels there are heavy glitches. This happens on all combinations of output ports I tested.

I read about similar problems in the net and here. I lowered PWM frequency with analogWriteFreq(200); even down to 40 Hz, tryed using yield(), nothing helped.

Disabling WiFi is not an option, cause this project is an NTP controlled clock.

Any suggestions?
Thanks in advance!

[1] NodeMCU Board V2, Arduino IDE 1.6.7,

Code: Select all#define QUART1  D3
#define QUART2  D4
#define QUART3  D5
#define QUART4  D6

unsigned int PWM_loop;

void setup() {
  analogWriteFreq(200);     // to avoid flicker due to other interrupts in esp?
  }

void loop()
  { 
  for (int PWM_loop=0; PWM_loop <= 1023; PWM_loop++){
    analogWrite(QUART1, PWM_loop);
    analogWrite(QUART2, PWM_loop);
    analogWrite(QUART3, PWM_loop);
    analogWrite(QUART4, PWM_loop);
    delay(5);
//    yield();
    }

  for (int PWM_loop=1023; PWM_loop >= 0; PWM_loop--){
    analogWrite(QUART1, PWM_loop);
    analogWrite(QUART2, PWM_loop);
    analogWrite(QUART3, PWM_loop);
    analogWrite(QUART4, PWM_loop);
    delay(5);
//    yield();
    }       
  }