Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AnalogOutput.ino flicker solution. #765

dmonty2 opened this Issue Apr 4, 2019 · 0 comments


None yet
1 participant
Copy link

dmonty2 commented Apr 4, 2019

With an Arduino Uno Nano ATMega328P running the example AnalogOutput.ino. There is a high frequency flicker on colors mixed between pin 3 and (pin 5 | pin 6 ).

  • pins 5 and 6 use "Fast PWM" on Timer0 at 980Hz.
  • pins 3 and 11 use "Phase-Correct PWM" on Timer2 at 490Hz

Solution on the SecretsOfArduinoPWM page was to set pins 3 and 11 Timer2 to "Fast PWM" at 976Hz with the following code:

void setup(){
// Change registers on ATmega168P/328P chips.
// Set pin 3 and 11 on Timer2 to 'Fast PWM' at 976Hz to match ping 5 and 6.
TCCR2A = _BV(COM2A1) | _BV(COM2B1) | _BV(WGM21) | _BV(WGM20);
TCCR2B = _BV(CS22);

I am using IRLB8721 Mosfets to drive 12v non-addressable RGB SMD5050 led strip as per these Adafruit RGB LED strip instructions. May want to put a note in AnalogOutput.ino to change to registers to match PWM mode and frequency. Or move it into the FastLED class to detect and handle PWM pin registers transparently in the background.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.