Fade LED with PWM

Requires

This project creates a smoothly fading LED effect using pulse-width modulation (PWM).

The circuit makes an LED gradually brighten and dim in a repeating pattern. Using PWM, the Arduino sends varying signals to the LED that change its brightness level. The code increases and decreases a brightness value, reversing direction when reaching maximum or minimum levels. A short delay between each change creates the smooth fading effect.

Parts List

  • Arduino board
  • LED (any colour)
  • 220-330 ohm resistor
  • Jumper wires
  • Breadboard

Assembly Instructions

  • Place the LED on the breadboard, noting the longer leg (anode/positive) and shorter leg (cathode/negative).
  • Connect the LED’s cathode (shorter leg) to the Arduino’s GND pin using a jumper wire.
  • Connect one end of the resistor to the LED’s anode (longer leg).
  • Connect the other end of the resistor to digital pin 9 on the Arduino using a jumper wire.