import board
import pwmio
import analogio
import time
# Create PWMOut objects for each LED
led = pwmio.PWMOut(board.GP26, frequency=5000)
led2 = pwmio.PWMOut(board.GP0, frequency=5000)
led3 = pwmio.PWMOut(board.GP1, frequency=5000)
# Assign pin A2 to potentiometer
potentiometer = analogio.AnalogIn(board.A2)
while True:
# Read the analog value from the potentiometer and scale it
brightness = potentiometer.value // 4 # Adjust scaling as needed
# Adjust the sleep duration for a smoother transition
time.sleep(0.05)
# Set the duty cycle for each LED based on the scaled potentiometer value
led.duty_cycle = brightness
led2.duty_cycle = brightness
led3.duty_cycle = brightness
# Print the brightness value for debugging or monitoring
print(brightness)