PWM Not Working
Arduino Microcontroller Board
Severity: ModerateWhat Does This Error Mean?
Arduino analogWrite not working is most often because the pin being used is not a PWM-capable pin. Only specific pins support PWM — on the Uno they are 3, 5, 6, 9, 10, and 11, marked with a ~ on the board silkscreen.
Affected Models
- Arduino Uno
- Arduino Mega
- Arduino Nano
- Arduino Leonardo
- Arduino Micro
Common Causes
- Non-PWM pin used with analogWrite() — only PWM pins output a variable duty cycle
- Pin used for tone() — the timer shared with that pin is taken over and disables PWM
- Timer conflict from a library (Servo, Tone, IRremote) that claims the same timer
- Wrong frequency for the application — Arduino default PWM frequency is fixed (490Hz or 980Hz)
- analogWrite value of 0 or 255 makes the pin fully off or on — this is correct behavior, not a bug
How to Fix It
-
Verify the pin supports PWM.
On Arduino Uno, only pins 3, 5, 6, 9, 10, and 11 support PWM (marked with ~ on the board). Using analogWrite() on any other pin will simply output digital HIGH or LOW depending on the value. Move your connection to a PWM-capable pin.
-
Check for tone() or Servo library conflicts.
tone() and the Servo library take over specific timers, disabling PWM on pins that share those timers. On Uno, tone() on any pin disables PWM on pins 3 and 11. Stop tone() with noTone(pin) before using analogWrite() on affected pins.
-
Check the analogWrite value range.
analogWrite() accepts values 0–255. A value of 0 outputs constant LOW (0% duty cycle, 0V) — this is correct, not a bug. A value of 255 outputs constant HIGH (100% duty cycle, 5V). Use values between 1 and 254 for actual PWM output.
-
Confirm with an LED test.
Connect an LED with a 220Ω resistor from the PWM pin to GND. Call analogWrite(pin, 127) in setup(). The LED should glow at half brightness. If it is fully off, the pin is not PWM capable. If fully bright, check if the pin is always HIGH due to a library conflict.
-
Check if a library has overridden the timer.
Search your sketch for all #include statements and identify any library that uses timers (Servo, IRremote, TimerOne, SoftwareSerial). Consult the library documentation to see which timer pins are affected. Use a PWM pin that is not sharing a timer with any active library.
When to Call a Professional
Arduino PWM is a hardware timer feature. If a confirmed PWM pin outputs nothing with analogWrite(), and the pin is confirmed not claimed by any library, the timer hardware may have been damaged.