PWM (Pulse Width Modulation)

Pulse Width Modulation (PWM) is a technique used to control the amount of power delivered to an electrical device using a digital signal. Instead of providing a steady voltage, PWM switches the signal on and off very quickly, and the ratio of “on” time to total cycle time—called the duty cycle—determines the effective power the device receives.

Key Concepts:

  • Duty Cycle: The percentage of time the signal is “on” during one cycle. For example:
    • 0% duty cycle → device is off
    • 50% duty cycle → device receives half the power
    • 100% duty cycle → device is fully on
  • Frequency: How fast the signal switches on and off. A higher frequency makes the device behave as if it’s receiving smooth analog power.

Applications of PWM:

  • LEDs: Dimming or brightening by changing the duty cycle
  • Motors: Controlling speed without using resistors
  • Fans: Adjusting airflow smoothly
  • Audio Signals: Generating tones or sound modulation

How It Works on Arduino:
Arduino uses the analogWrite() function on certain pins to generate a PWM signal. Even though Arduino pins are digital (on/off), PWM allows you to simulate varying voltage levels so devices behave like they are receiving analog power.

Example:

  • analogWrite(pin, 128) → roughly 50% brightness for an LED
  • analogWrite(pin, 255) → full brightness
  • analogWrite(pin, 0) → LED off

Summary:
PWM is a powerful, efficient way to control electrical devices using digital signals. It’s widely used in electronics because it’s easy to implement and doesn’t waste energy like traditional resistive dimming.