Skip to content
Lifestyle & Learning

Arduino PWM Control Technical Details of Frequency and Resolution

In this article

Pulse Width Modulation (PWM) on Arduino platforms is a technique used to encode analog signal levels into digital pulses by varying the duty cycle of a square wave. The frequency determines how often the cycle repeats, while the resolution defines the number of discrete steps available to adjust the pulse width. Mastering these technical parameters allows for precise control over motors, LEDs, and power electronics.

In the landscape of 2026, Arduino hardware has expanded significantly from the classic 8-bit AVR microcontrollers to powerful 32-bit ARM and RISC-V architectures. Despite these advancements, the fundamental physics of PWM remains rooted in how hardware timers interact with the system clock. Understanding the relationship between the master clock, prescalers, and timer registers is essential for any engineer or developer looking to push beyond the default limitations of the analogWrite() function.

The Fundamentals of PWM Frequency

Frequency in the context of PWM refers to the number of complete on-off cycles completed per second, measured in Hertz (Hz). For a standard Arduino Uno (utilizing the ATmega328P), the default PWM frequency is approximately 490 Hz for most pins, except for pins 5 and 6, which run at approximately 980 Hz.

The frequency is dictated by the system clock frequency and the configuration of the internal hardware timers. In 8-bit AVR microcontrollers, the formula for calculating the PWM frequency in Fast PWM Mode is:

Frequency = System Clock / (Prescaler × Number of Steps)

For a standard 16 MHz Arduino Uno using an 8-bit timer (256 steps) and a prescaler of 64, the calculation is 16,000,000 / (64 × 256), which results in 976.56 Hz. If you change the prescaler to 1, the frequency jumps to 62.5 kHz. Selecting the right frequency is a balancing act; high frequencies are necessary to avoid audible whining in motors or flickering in high-speed optical systems, while lower frequencies reduce switching losses in power transistors like MOSFETs.

The Technicality of PWM Resolution

Resolution refers to the "granularity" of the duty cycle. It is the number of discrete increments between "fully off" (0% duty cycle) and "fully on" (100% duty cycle). In the Arduino environment, resolution is typically expressed in bits.

An 8-bit resolution provides 256 possible values (0 to 255). This is the default for most standard Arduino functions. However, as we look at more advanced applications in 2026, such as high-fidelity audio synthesis or precision laboratory power supplies, 8-bit resolution is often insufficient.

Higher resolution allows for smoother transitions. For instance, a 10-bit resolution offers 1,024 steps, and 12-bit resolution offers 4,096 steps. The physical constraint is that resolution and frequency are inversely proportional on a fixed-clock system. If you want more steps (higher resolution), the timer must count higher before resetting, which takes more time and thus lowers the frequency.

Heating Element with PWM and PID control - General Guidance - Arduino Forum
Heating Element with PWM and PID control - General Guidance - Arduino Forum

Hardware Timers and Prescalers

The heart of Arduino PWM control lies in the hardware timers. Most Arduino boards have multiple timers, each capable of controlling specific PWM pins.

  1. Timer 0: Usually an 8-bit timer. On the Uno, it controls pins 5 and 6. It is also responsible for internal time-keeping functions like millis() and delay(). Modifying the frequency of Timer 0 can break these timing functions, making it a "protected" resource for many developers.
  2. Timer 1: A 16-bit timer on the Uno and Mega, controlling pins 9 and 10. Because it is 16-bit, it can count up to 65,535, allowing for much higher resolution or very low frequencies without sacrificing precision.
  3. Timer 2: Another 8-bit timer, controlling pins 3 and 11. It is often used for specialized libraries like "Tone" or infrared communication.

Prescalers act as clock dividers. The system clock (e.g., 16 MHz) is too fast for many PWM applications, so the prescaler divides the clock by a fixed factor—typically 1, 8, 64, 256, or 1024. If you set a prescaler of 8 on a 16 MHz clock, the timer increments at 2 MHz. This allows the hardware to generate a wider range of frequencies.

PWM Modes: Fast PWM vs. Phase Correct PWM

The way the timer counts determines the "flavor" of the PWM signal. There are two primary modes used in the Arduino ecosystem.

Fast PWM Mode is a single-slope operation. The timer counts from 0 up to a top value (usually 255) and then immediately resets to 0. The output pin toggles when the timer matches a comparison value. Because it resets instantly, it can achieve higher frequencies, which is ideal for power regulation and LED dimming.

Phase Correct PWM Mode is a dual-slope operation. The timer counts from 0 up to a top value and then counts back down to 0. This results in a symmetrical waveform. While the maximum frequency is halved compared to Fast PWM, the phase-correct nature is critical for motor control applications. In multi-phase motor setups, having the centers of the pulses aligned (rather than the edges) reduces electromagnetic interference (EMI) and motor vibration.

Comparison of PWM Capabilities Across Arduino Boards (2026 Status)

The capabilities of Arduino boards have diverged as newer microcontrollers enter the market. The following table illustrates the technical specifications for PWM control across the most common platforms available in 2026.

Board Model Architecture Primary PWM Pins Standard Resolution Max Frequency (approx.) Timer Count
Arduino Uno R3 AVR (8-bit) 3, 5, 6, 9, 10, 11 8-bit 62.5 kHz 3
Arduino Mega 2560 AVR (8-bit) 2 to 13, 44 to 46 8-bit 62.5 kHz 6
Arduino Due ARM Cortex-M3 All Digital Pins 8 to 12-bit 84 MHz (Clock) 9
Arduino Uno R4 Minima Renesas RA4M1 3, 5, 6, 9, 10, 11 8 to 14-bit 48 MHz (Clock) 7
Arduino GIGA R1 STM32H7 12 PWM Pins Up to 16-bit 480 MHz (Clock) 12+
ESP32 (Arduino Core) Tensilica/RISC-V 16 Channels 1 to 16-bit 40 MHz (at 1-bit) 4

Advanced Register Control for Frequency Adjustment

To change the PWM frequency beyond the standard analogWrite() defaults, developers must manipulate the microcontroller's registers directly. This requires bypassing the abstraction layer of the Arduino IDE.

On an ATmega328P, the TCCR (Timer/Counter Control Register) is used. For example, TCCR1B controls the prescaler for Timer 1. By setting the specific bits (CS12, CS11, CS10), a user can shift the frequency of pins 9 and 10.

For example, on Timer 1:

  • Setting the prescaler to 1 results in 31.25 kHz (Phase Correct) or 62.5 kHz (Fast PWM).
  • Setting the prescaler to 8 results in 3.9 kHz or 7.8 kHz.
  • Setting the prescaler to 1024 results in 30 Hz or 61 Hz.

Accessing these registers is the only way to achieve "silent" motor control. Most humans can hear frequencies up to 20 kHz. The default 490 Hz creates a very audible and often annoying buzz in DC motors. Shifting the PWM frequency to 25 kHz or higher moves the vibration into the ultrasonic range, making the motor operation silent to the human ear.

Impacts of PWM Frequency on Components

Choosing a PWM frequency is not just a software decision; it has physical consequences for the hardware components involved.

1. MOSFETs and Switching Losses

When a MOSFET switches from an OFF state to an ON state, it passes through a linear region where its resistance is high. During this transition, it generates heat. If the PWM frequency is too high, the MOSFET spends a larger percentage of its time in this "transitional" state, leading to excessive heat buildup. For high-power applications, frequencies between 5 kHz and 20 kHz are often the "sweet spot."

2. Inductors and Capacitors

In LC filters (used to smooth PWM into a true analog voltage), higher frequencies allow for the use of smaller inductors and capacitors. This is why modern switching power supplies operate at hundreds of kilohertz or even megahertz—it reduces the physical footprint of the device.

3. Human Perception (The Flicker Effect)

For LED dimming, the frequency must be high enough that the human eye cannot perceive the "off" periods. While 60 Hz is often cited as the limit, many people can perceive flicker up to 200 Hz or even higher in their peripheral vision. Arduino's default 490 Hz is generally sufficient to prevent visible flicker, but in high-speed videography, a much higher frequency (2 kHz+) is required to avoid "banding" on camera sensors.

Resolution Limits and Technical Constraints

The primary constraint in 2026 remains the Timer Clock. If you have a 16 MHz clock and you desire a 10-bit resolution (1,024 steps), the maximum frequency you can achieve is 16,000,000 / 1,024 = 15.625 kHz.

If you require a 16-bit resolution (65,536 steps) for extremely precise control, your frequency drops significantly: 16,000,000 / 65,536 = 244 Hz. This low frequency might be acceptable for a slow-acting heating element, but it would be disastrous for a high-speed drone motor.

This is why boards like the Arduino GIGA R1 or ESP32 are preferred for high-resolution tasks. With a 480 MHz clock, the GIGA R1 can maintain high frequencies even at 16-bit resolutions, providing both the precision and the speed required for modern robotics and industrial automation.

Common Mistakes and Troubleshooting

When working with custom PWM frequencies and resolutions, several common issues can arise:

  • Interference with System Functions: As mentioned, changing Timer 0 affects millis(). If your project relies on accurate timing or the delay() function, avoid modifying Timer 0. Use Timer 1 or Timer 2 instead.
  • Incompatible Libraries: Many libraries (such as Servo.h or IRremote) rely on specific hardware timers. If you manually reconfigure a timer that a library is using, the library will cease to function or exhibit erratic behavior.
  • Duty Cycle "Glitches": At very high frequencies or when updating PWM values frequently, you might encounter "glitches" where the pulse is skipped or doubled. Using Double Buffering (available on more advanced ARM-based Arduinos) ensures that the new duty cycle value is only updated at the beginning of a new cycle, preventing these artifacts.

Frequently Asked Questions

Can I change the PWM frequency on a per-pin basis?

PWM frequency is tied to the hardware timer, not the individual pin. Because most timers control at least two pins, changing the frequency for one pin will inevitably change it for the other pin associated with that timer. For example, on an Uno, changing the frequency of pin 9 will also change the frequency of pin 10.

What is the maximum PWM resolution possible on an Arduino Uno?

The standard analogWrite() is 8-bit. However, Timer 1 is a 16-bit timer. By directly manipulating the ICR1 (Input Capture Register) or OCR1A/B registers, you can achieve up to 16-bit resolution (65,536 steps), though this will significantly limit your maximum frequency.

Does increasing PWM frequency reduce motor torque?

Generally, no, but it does change the motor's behavior. Higher frequencies can lead to higher inductive reactance, which might slightly reduce the peak current in each pulse. However, the most significant impact is on heat and efficiency. Low frequencies can cause "cogging" at low speeds, while high frequencies provide smoother rotation but might increase heat in the controller.

Why is the default frequency different on pins 5 and 6?

On the Arduino Uno, pins 5 and 6 are controlled by Timer 0. To provide accurate timekeeping for the millis() and micros() functions, Timer 0 is configured to run at a higher frequency (approximately 980 Hz) with a specific prescaler. This is a design choice made by the Arduino team to balance timing accuracy with PWM utility.

How do I achieve a true analog output instead of PWM?

PWM only simulates analog. To get a true analog voltage, you must use a board with a Digital-to-Analog Converter (DAC), such as the Arduino Due, GIGA R1, or the Uno R4 Minima. Alternatively, you can pass a high-frequency PWM signal through a low-pass filter (a resistor and a capacitor) to smooth the pulses into a steady DC voltage.

Recommendation for Next Actions

For users looking to implement custom PWM control, the first step is to identify the requirements of your load. If you are controlling a DC motor, aim for a frequency above 20 kHz to eliminate audible noise. If you are dimming high-power LEDs for video, aim for at least 4 kHz.

Start by utilizing the Timer 1 16-bit capabilities on an Uno or Mega, as it offers the most flexibility without breaking core system functions. If your project requires multiple high-speed, high-resolution PWM channels, 2026 standards suggest migrating to an ESP32 or Arduino Uno R4, where the analogWriteResolution() and analogWriteFrequency() functions are often supported natively, removing the need for direct register manipulation. Always verify the thermal limits of your switching components when increasing frequency.