from machine import Pin, PWM, ADC
import time
# Setup LED with PWM on GPIO15
led = PWM(Pin(15))
led.freq(1000) # Set PWM frequency to 1kHz
# Setup Potentiometer on ADC0 (GPIO26)
pot = ADC(Pin(26))
while True:
pot_value = pot.read_u16() # Read ADC (0–65535)
led.duty_u16(pot_value) # Set LED brightness = pot value
time.sleep(0.01) # Small delay for stability