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)











留言

這個網誌中的熱門文章

使用PWM控制伺服馬達-micropython

DHT11+OLED+IFTTT+LINE-notity-micropython

BMP280氣壓,溫度模組-micropython