Post topics, source code that relate to the Arduino Platform

User avatar
By ArnieO
#35012 Using analogWrite(GPIO, value) to a GPIO pin gives a PWM signal that can be used for instance to fade LEDs.
It has 10 bit resolution, input values ranging from 0 through 1023.
So far so good.
However, I see instabilities for the highest values:
1023: OK, gives a flat signal
In the range 1022 down to around 1010 the signal becomes unstable, with short bursts of wrong pulses at seemingly random intervals from half a second to several seconds.
From around 1010 and downwards, it seems to be stable.
Has anyone else seen this?
I think it might be an error in the Arduino IDE compiler, as I am running several LED faders programmed with LUA, and I have never seen this issue on those modules.
Last edited by ArnieO on Thu Nov 26, 2015 3:46 pm, edited 1 time in total.
User avatar
By ArnieO
#35101 After some searching, I found this is a known issue: https://github.com/esp8266/Arduino/issues/836

I found a workaround that gets rid of the flickering on my ESP-03: Reduce the PWM frequency to 200 Hz:
Code: Select allanalogWriteFreq(200);

I found this to be the highest frequency that avoided flickering on my ESP-03. Other modules might need an other frequency, so you might need to do some trials.