What Is PWM and Why Is My LED Flickering?

PWM is pulse width modulation. It turns a pin on and off very fast to simulate a lower voltage. The flicker happens when the PWM frequency is low enough for your eyes or camera to notice.

Why flicker happens

  • Low PWM frequency on some boards.
  • Short duty cycle values that look like flashes.
  • Cameras can capture flicker even when your eyes do not.

How to reduce flicker

  1. Increase PWM frequency if your board supports it.
  2. Use a different pin with a higher PWM timer.
  3. For video, use a constant current LED driver.
Bottom line

PWM is fast blinking. If you see flicker, raise the PWM frequency or use a proper LED driver.

Related: Why does analogWrite not work on this pin? · Do I need a resistor for my LED? · What is the difference between digital and analog pins?