PWM-呼吸燈-micropython

 PWM-呼吸燈


所需零件

  • ESP32
  • 5mm LED
  • 330 歐姆電阻
  • 麵包板
  • 跳線

程式碼

from machine import PinPWM
from time import sleep

led = PWM(Pin(4), freq=5000)
while True:
    for duty_cycle1 in range(0100010):
        led.duty(duty_cycle1)
        sleep(0.05)
    for duty_cycle2 in range(10000, -10):
        led.duty(duty_cycle2)
        sleep(0.05)











留言

這個網誌中的熱門文章

天氣光環時鐘+農曆提醒(NODE-RED)專題作品-micropython