PWM (Pulse Width Modulation)

Digital signal technique that simulates analog output by varying the duty cycle — the fraction of time the signal is HIGH.

  • Signal is always HIGH (3.3V) or LOW (0V) — never in between
  • Duty cycle = (time HIGH / period) × 100%
  • 0% = always off, 50% = half, 100% = always on

Applications:

  • LED dimming: rapid switching tricks the eye
  • Servo motors: pulse width determines arm position
from gpiozero import PWMLED, Servo
led = PWMLED(17)
led.value = 0.5   # 50% brightness
 
servo = Servo(17)
servo.min()  # minimum position
servo.max()  # maximum position

See Also