PWM LED Fade Effect on Raspberry Pi | Wokwi Simulation (MicroPython)

Опубликовано: 14 Май 2026
на канале: StudyHive
19
1

PWM LED Fade Effect on Raspberry Pi | Wokwi Simulation (MicroPython)

This video demonstrates a smooth LED fade-in and fade-out effect using PWM on a Raspberry Pi Pico, simulated in Wokwi.
The LED brightness gradually increases and decreases using duty-cycle control in MicroPython.
Perfect for engineering assignments, beginners, and anyone exploring PWM concepts.

What this simulation includes:
• Raspberry Pi Pico in Wokwi
• LED + 220Ω protective resistor
• PWM at 1 kHz
• Smooth brightness fade using MicroPython
• Step-by-step code execution

Source Code Used:

from machine import Pin, PWM
from time import sleep

led = PWM(Pin(15))
led.freq(1000)

step = 1024
delay = 0.02

while True:
for duty in range(0, 65535, step):
led.duty_u16(duty)
sleep(delay)

for duty in range(65535, -1, -step):
led.duty_u16(duty)
sleep(delay)


If you're learning PWM, MicroPython, Embedded Systems, or Raspberry Pi basics, this is a great starting point.

#raspberrypi #raspberrypipico #wokwi #micropython #ledcontroller #electronicsproject #engineeringprojects #embeddedsystems #iotprojects #stemprojects #techlearning #makerprojects