This example uses the Adafruit’s pulseio package to create a PWMOut object.
import time import board import pulseio led = pulseio.PWMOut(board.IO0, frequency=5000, duty_cycle=0) while True: for i in range(100): # PWM LED up and down if i < 50: # Up led.duty_cycle = int(i * 2 * 65535 / 100) else: # Down led.duty_cycle = 65535 - int((i - 50) * 2 * 65535 / 100) time.sleep(0.01)
Page last edited March 08, 2024
Text editor powered by tinymce.