Same-day dispatch before 2 PM · Free delivery over ₹999 · GST invoices Get the appPrices incl. GST
Geekobot
Snap & SendNEWGeeko AIWhere's myOrder
Log in
Products
  • Projects
    • Component guidesHow parts work, with code you can run
    • Learning pathsFrom your first LED to your first robot
    • Workshops & eventsOnline sessions for makers and classes
    • ElectrolarkFree guided builds, simulator and certificates
    • Students & teachersStudent discount and classroom help
    • CommunityShare builds and ask other makers
    • CalculatorsOhm's law, LED resistor, 555 and 100+ more
    • Circuit builderWire parts and run the circuit, powered by Electrolark
    • Geeko AIAsk what to buy or how to wire it
    • Snap & SendPhotograph a part or list, we find it
    • Part finderAnswer a few questions, get the right part
    • Compatibility checkWill these two parts work together?
    • Compare partsSpecs side by side
    • Business & bulk ordersGST invoices, credit and volume prices
    • Request a quotationSend your list, get a quote
    • Classroom kitsPer-student kits and lab bundles
    • Gift cardsFor students, teams and events
  • Atal Tinkering Lab
BOM to cart
Geekobot

Components, kits and know-how for makers, students, engineers, labs and businesses across India.

Ask Geeko AIOrders, parts and projects, any timeEmail supportReply within 1 working dayGet the Geekobot appAdd it to your home screen, free

Follow us

Shop

  • Boards & SBCs
  • Sensors & Modules
  • IoT & Wireless
  • Drone & FPV
  • 3D Printing
  • Filaments & Resins
  • Motors & Drivers
  • Power & Batteries
  • Semiconductors
  • Passive
  • Displays & LEDs
  • Switches & Relays
  • Wires & Cables
  • Prototyping
  • Tools & Test
  • Robotics
  • STEM Kits
  • Atal Tinkering Lab
  • Mechanical Parts
  • Audio

Orders

  • Track your order
  • Help & support
  • Shipping and delivery
  • Refunds and cancellation
  • Contact us

Learn

  • Projects
  • Geeko AI project assistant
  • Learning paths
  • Guides
  • Calculators
  • Electrolark: free guided builds

Part tools

  • Part finder
  • Compare parts
  • Will it work with my board?

Institutions

  • Classroom kits
  • Atal Tinkering Lab
  • Students & teachers
  • Workshops & Events

Business

  • Business & education
  • Request a quotation
  • BOM bulk upload
  • Quick order by SKU

Company

  • About Geekobot
  • Community
  • Gift cards
  • Terms & conditions
  • Privacy policy
  • Product directory
  • Sitemap

© 2026 Geekobot, a trade name of OLatus Systems Private Limited. All rights reserved.

20, 1st Floor, Neeladri Complex, 10th Cross, Sampige Rd, 2nd Main, Malleshwaram, Bengaluru, Karnataka 560003 · GSTIN 29AACCO0462F1ZM

+91 91810 15607 · connect@geekobot.in · Monday to Saturday, 10 AM to 2 PM IST

UPI · CARDS · NETBANKING · GST INVOICES

ShopProjectsGeeko AIGuides
Compare 0 parts →
Log in

Shop by category

Shop all components
  • Boards & SBCs1,910 products
    • Alternative Single Board Computers
    • Arduino Ecosystem
    • FPGA & Logic Boards
    • Microcontroller & Wireless Boards
    View all
  • Sensors & Modules4,701 products
    • Biomedical & Heart Rate
    • Current, Voltage & Power
    • Force, Weight & Pressure
    • Gas, Weather & Environmental
    View all
  • IoT & Wireless2,314 products
    • RF Modules
    • RFID & NFC
    • Antennas & RF Accessories
    • Cameras & Smart Vision
    View all
  • Drone & FPV3,558 products
    • Flight Control & Navigation
    • FPV Video & Optics
    • Frames & Structural Parts
    • Motors & Propulsion
    View all
  • 3D Printing2,204 products
    • 3D Printers
    • 3D Scanners & Digitizers
    • Laser Engravers & Cutters
    • Material Management & Upgrades
    View all
  • Filaments & Resins1,472 products
    • Filaments
    • Photopolymer Resins
    View all
  • Motors & Drivers463 products
    • BLDC Motor Drivers
    • DC & Geared Motors
    • DC Motor Drivers
    • Linear Actuators & Solenoids
    View all
  • Power & Batteries557 products
    • Battery Holders & Connectors
    • Breadboard Power
    • Chargers & BMS
    • DC-DC Converters
    View all
  • Semiconductors295 products
    • Diodes & Rectifiers
    • Interface & RF Encoder ICs
    • Logic ICs (74xx)
    • Logic ICs (CD4000)
    View all
  • Passive67 products
    • Capacitors
    • Circuit Protection
    • Crystals & Oscillators
    • Inductors
    View all
  • Displays & LEDs572 products
    • 7-Segment & Dot Matrix
    • Addressable LEDs
    • Character LCDs
    • Graphic LCDs
    View all
  • Switches & Relays184 products
    • Keypads & Touch
    • Push Buttons & Tactile
    • Relay Modules
    • Relays
    View all
  • Wires & Cables233 products
    • Board-to-Wire Connectors
    • Crimp & Splice
    • Headers & Dupont
    • Heat Shrink & Sleeving
    View all
  • Prototyping101 products
    • Breadboards
    • Interface Modules
    • PCBs & Perfboards
    View all
  • Tools & Test717 products
    • Bench Power Supplies
    • Hand Tools
    • Measuring Tools
    • Meters & Testers
    View all
  • Robotics180 products
    • Humanoid & Legged Robots
    • Robot Chassis & Platforms
    • Robotic Arms & Grippers
    • Wheels & Casters
    View all
  • STEM Kits268 products
    • Arduino Learning Kits
    • Coding & IoT Kits
    • Early Coding (Ages 3-8)
    • Invention Kits
    View all
  • Atal Tinkering Lab196 products
    • Package 1: Electronics, Robotics, IoT and Sensors
    • Package 2: Rapid Prototyping Tools
    • Package 3: Mechanical, Electrical and Measurement Tools
    • Package 4: Power Supply, Accessories and Safety Equipment
    View all
  • Mechanical Parts212 products
    • Bearings
    • Brackets & Mounts
    • Couplers
    • Fasteners & Standoffs
    View all
  • Audio109 products
    • Amplifier Modules
    • Buzzers & Sirens
    • Speakers
    View all
  1. Home
  2. ›Guides
  3. ›Electronics Fundamentals
  4. ›PWM Explained
Step 10 of 18 in Electronics from zeroPart of a learning path.
Next

Concept explainer · Beginner · 3 min read

PWM Explained

Duty Cycle, Frequency and How to Use It

By Geekobot Learning Team · Updated 24 Oct 2026

On this page
Short answerHow PWM worksPWM on Arduino, ESP32 and PicoCode examplesWhich PWM frequency should you use?Turning PWM into a real analog voltagePWM vs servo controlTry itCommon mistakesFAQsParts and next steps
Short answer

PWM (pulse-width modulation) switches a pin fully on and off very quickly; the share of time it is on, the duty cycle, sets the average power. 50% duty on a 5 V pin acts like 2.5 V for an LED or motor. Arduino's analogWrite() gives 8-bit PWM at about 490 Hz; the ESP32 and Pico let you set both frequency and resolution.

Key specs at a glance

Duty cycle
On time as a percentage of the period, 0 to 100%
Frequency
Pulses per second; Arduino Uno default 490 Hz (980 Hz on pins 5 and 6)
Resolution
8-bit (0 to 255) on classic Arduino; up to 16-bit on ESP32 and Pico
Arduino
analogWrite(pin, 0 to 255) on ~ pins
ESP32
ledcAttach(pin, freq, resolution), ledcWrite(pin, duty)
Pico (MicroPython)
PWM(Pin(n)), freq(), duty_u16(0 to 65535)
Servo signal
50 Hz, 1 to 2 ms pulse (not a duty cycle you set directly)
01

How PWM works

A digital pin can only be fully on or fully off. PWM turns it on and off thousands of times a second. If it is on 25% of the time, an LED looks a quarter as bright and a motor runs at about a quarter speed, because the load averages the pulses. The eye and a motor's inertia smooth the flicker; a capacitor and resistor can smooth it into a true analog voltage.

02

PWM on Arduino, ESP32 and Pico

BoardPinsResolutionFrequencyCall
Arduino Uno / Nano3, 5, 6, 9, 10, 118-bit490 Hz (980 Hz on 5, 6)analogWrite(pin, 0-255)
Arduino Uno R43, 5, 6, 9, 10, 118-bit default, up to 12-bit490 Hz defaultanalogWrite(), analogWriteResolution()
ESP32Almost any GPIO, 16 channels1 to 16-bit1 Hz to 40 MHz (depends on bits)ledcAttach(), ledcWrite()
Raspberry Pi PicoAll GPIO, 16 slices16-bit8 Hz to 62 MHzPWM(Pin(n)).duty_u16()
Raspberry Pi 5GPIO 12, 13, 18, 19 hardwareSet per requestAny practicalgpiozero PWMLED / PWMOutputDevice
Arduino Uno / Nano
Pins:
3, 5, 6, 9, 10, 11
Resolution:
8-bit
Frequency:
490 Hz (980 Hz on 5, 6)
Call:
analogWrite(pin, 0-255)
Arduino Uno R4
Pins:
3, 5, 6, 9, 10, 11
Resolution:
8-bit default, up to 12-bit
Frequency:
490 Hz default
Call:
analogWrite(), analogWriteResolution()
ESP32
Pins:
Almost any GPIO, 16 channels
Resolution:
1 to 16-bit
Frequency:
1 Hz to 40 MHz (depends on bits)
Call:
ledcAttach(), ledcWrite()
Raspberry Pi Pico
Pins:
All GPIO, 16 slices
Resolution:
16-bit
Frequency:
8 Hz to 62 MHz
Call:
PWM(Pin(n)).duty_u16()
Raspberry Pi 5
Pins:
GPIO 12, 13, 18, 19 hardware
Resolution:
Set per request
Frequency:
Any practical
Call:
gpiozero PWMLED / PWMOutputDevice
03

Code examples

PWM fade on Arduino and ESP32 · Arduino C++Verify & upload in Electrolark
// Arduino Uno: pin 9 is a ~ (PWM) pin
void setup() { pinMode(9, OUTPUT); }
void loop() {
  for (int d = 0; d < 256; d++) { analogWrite(9, d); delay(4); }
}

// ESP32 (arduino-esp32 3.x): 5 kHz, 10-bit resolution on GPIO 18
// void setup() { ledcAttach(18, 5000, 10); }
// void loop()  { for (int d = 0; d < 1024; d++) { ledcWrite(18, d); delay(2); } }
04

Which PWM frequency should you use?

LoadSuggested frequencyWhy
LEDs (indicator, strips through MOSFET)1 to 20 kHzAbove 1 kHz no visible flicker; higher avoids camera banding
DC motors through a driverUnder 1 kHz for L298N; 15 to 25 kHz for MOSFET driversSub-kHz whines audibly; 20 kHz+ is silent and efficient on MOSFET drivers
Hobby servos50 Hz exactlyThe servo reads the pulse width, not the duty
Heaters, SSR (slow)1 to 10 HzZero-cross SSRs cannot switch fast
PWM to analog (DAC)10 kHz+ with an RC filterEasier to filter at high frequency
LEDs (indicator, strips through MOSFET)
Suggested frequency:
1 to 20 kHz
Why:
Above 1 kHz no visible flicker; higher avoids camera banding
DC motors through a driver
Suggested frequency:
Under 1 kHz for L298N; 15 to 25 kHz for MOSFET drivers
Why:
Sub-kHz whines audibly; 20 kHz+ is silent and efficient on MOSFET drivers
Hobby servos
Suggested frequency:
50 Hz exactly
Why:
The servo reads the pulse width, not the duty
Heaters, SSR (slow)
Suggested frequency:
1 to 10 Hz
Why:
Zero-cross SSRs cannot switch fast
PWM to analog (DAC)
Suggested frequency:
10 kHz+ with an RC filter
Why:
Easier to filter at high frequency
05

Turning PWM into a real analog voltage

Put a resistor and capacitor in series from the PWM pin to ground and take the voltage across the capacitor. With 4.7 kΩ and 10 µF the filter smooths a 1 kHz signal to a steady average with small ripple. For a clean DAC output use a dedicated DAC (the ESP32 has two, the MCP4725 works over I2C).

06

PWM vs servo control

Servos use a 50 Hz signal, but the information is the pulse length (1 to 2 ms), not the duty cycle. Use the Servo library or a PCA9685 rather than analogWrite. See servo motors.

07

Try it: PWM duty cycle calculator

Change the values and the diagram and results update as you type.

08

Common mistakes to avoid

  • !Using analogWrite on a non-PWM Arduino pin, which just switches it on or off.
  • !Driving motors at 490 Hz through a MOSFET and getting an audible whine; raise the frequency.
  • !Calling analogWrite for a servo instead of the Servo library.
  • !Expecting PWM to produce a true analog voltage without a filter.
  • !Using an SSR with a kHz PWM; zero-cross SSRs cannot keep up.
09

Frequently asked questions

What does PWM stand for?

Pulse-width modulation: varying the width (on time) of fixed-frequency pulses to control the average power delivered to a load.

What is duty cycle?

The fraction of each PWM period that the signal is on. 75% duty cycle means on three-quarters of the time, so an LED looks about three-quarters bright.

Which Arduino pins support PWM?

On the Uno and Nano: pins 3, 5, 6, 9, 10 and 11, marked with a tilde (~). The Mega has 15 PWM pins.

Can I change the PWM frequency on an Arduino?

Yes, by changing timer prescalers, but it affects millis() on some timers. The ESP32 and Pico let you set frequency directly in code.

Is PWM the same as analog output?

No. PWM is a digital on-off signal whose average equals an analog level. It works for LEDs, motors and heaters, but needs an RC filter or a DAC to make a steady voltage.

Parts for this guide

  • TB6612FNG Dual Motor Driver Module
    ₹130View
  • Electrolytic Capacitor
    ₹16View
Shop Arduino BoardsShop DC Motor Drivers

Calculators

PWM duty cycle calculatorRC filter calculatorADC resolution calculator

Terms in this guide

PWMPulse-width modulation: switching a signal on and off quickly so its average sets brightness, speed or position.Duty cycleThe percentage of time a PWM signal is high. 50% duty is on half the time.FrequencyHow many times per second a signal repeats, measured in hertz (Hz). 1 kHz is 1000 cycles per second.ResolutionThe smallest step a measurement or output can represent. A 12-bit ADC on 3.3 V has steps of about 0.8 mV.DACDigital-to-analog converter: turns a number into a real voltage. The ESP32 has two 8-bit DACs; the Uno has none and uses PWM instead.RC filterA resistor and capacitor in series that smooths a signal, turning PWM into a steady voltage or removing high-frequency noise.

Projects that use it

Put this into practice: 8 step-by-step builds in our project library use parts from this guide.

Beginner · 1 hourDC fan speed controllerView projectBeginner · 1 hourTemperature-controlled laptop stand fanView projectIntermediate · 1–2 hours555 PWM motor speed controllerView project
Browse all 8 projects

Keep learning

Component guideBeginnerLEDs ExplainedAn LED (light-emitting diode) lights when current flows from its longer leg (anode, +) to its shorter leg (cathode, -).3 min read · Displays & LEDsComponent guideBeginnerDC Motors ExplainedA brushed DC motor spins when current flows through it: voltage sets the speed and the load sets the current it draws.4 min read · Motors & MotionComponent guideBeginnerServo Motors GuideA hobby servo is a small motor with a gearbox, position sensor and control circuit that moves to an angle you set with a pulse signal.3 min read · Motors & MotionHow-toIntermediateTransistors and MOSFETs as SwitchesA transistor lets a small microcontroller signal switch a much larger current.4 min read · Semiconductors & ICsComponent guideBeginnerESP32 GuideThe ESP32 is a low-cost 3.3 V microcontroller from Espressif with built-in Wi-Fi and Bluetooth, used for IoT devices, smart-home controllers and web dashboards.5 min read · Boards & Microcontrollers

Sources

  • Arduino analogWrite() reference (Arduino)
  • ESP32 LED Control (LEDC) documentation (Espressif Systems)
  • RP2040 datasheet, PWM chapter (Raspberry Pi Ltd)

Written by the Geekobot team from manufacturer datasheets. Always check the datasheet for the exact part and variant you buy.

On this page
Short answerHow PWM worksPWM on Arduino, ESP32 and PicoCode examplesWhich PWM frequency should you use?Turning PWM into a real analog voltagePWM vs servo controlTry itCommon mistakesFAQsParts and next steps
Need a hand?Ask Geeko AI which part fits your project, or talk to the Geekobot team.Ask Geeko AIHelp & support

Parts for this guide2 items · ₹146

TB6612FNG Dual Motor Driver Module · Electrolytic Capacitor

Run itChange the inputs and watch the output
Pin 9 OFF
Duty cycle0/255 = 0 %

A simulation of the sketch above, so you know what to expect. Real readings vary with your parts and wiring.

Ask the Community

Ask a question