Motor whines or hums with analogWrite: Arduino PWM frequency

Low PWM frequency makes small motors whine because you can hear it. The Arduino Uno gives about 490 Hz on most PWM pins and about 980 Hz on pins 5 and 6.

What the message means

The motor coil and the driver switch at the PWM frequency. In the audio range this is heard as a hum or whine, and low frequencies also make the motor run less smoothly at low speed.

Fix it in this order

  1. Note which pin you use. On an Uno, pins 5 and 6 run near 980 Hz and the others near 490 Hz.
  2. Raise the frequency by changing the timer prescaler, or use a library made for your board. Changing a timer can disturb millis(), delay() and Servo on that timer.
  3. Check the driver datasheet for its maximum PWM frequency, and stay below it.
  4. On an ESP32 set the frequency in ledcSetup or ledcAttach; frequencies above the audible range are easy there.
  5. Add a small capacitor across the motor terminals if the noise is electrical rather than acoustic.

Why it happens

The default analogWrite() frequency on an Uno is about 490 Hz on pins 3, 9, 10 and 11 and about 980 Hz on pins 5 and 6. That is in the audible range, so the motor whines. A higher PWM frequency moves the sound above hearing.

On pins 9 and 10 (Timer 1) you can raise the frequency to about 31 kHz with one line in setup(). Do not change Timer 0, because millis() and delay() depend on it. Check that your motor driver accepts the higher frequency.

void setup() {
  TCCR1B = (TCCR1B & 0xF8) | 0x01;   // Timer 1 prescaler 1: about 31 kHz on pins 9 and 10 (Uno)
}

Example sketch: change pins and values for your own wiring. It has not been bench-tested on your hardware.

If you see this, do this

You seeDo this
Whine at low speed onlyRaise the PWM frequency.
Servo or delay() breaks after timer changeYou changed the timer they use.

Arduino Uno pinout for robotics, motor runs one direction.

Last reviewed: November 2026. These are the usual causes and the order that finds them fastest. Test on your own board; clones and cables differ.