##############################################
# IMPORT LIBRARIES
##############################################
from machine import Pin, ADC
from utime import sleep
##############################################
# PIN CONFIGURATIONS
##############################################
# Replace 'x' with the ADC pin connected to the potentiometer
pot_pin = ADC(Pin(0))
# Replace 'y' with the GPIO pin connected to the LED
led = Pin(2, Pin.OUT)
##############################################
# MAIN ROUTINE
##############################################
def main():
while True:
# Read the potentiometer value (0–4095 on most boards)
pot_value = pot_pin.read()
print("Potentiometer Value:", pot_value)
# LED control based on potentiometer reading
if pot_value < 2100:
led.off()
else:
led.on()
# Small delay for stability
sleep(0.1)
##############################################
# EXECUTE MAIN ROUTINE
##############################################
if __name__ == "__main__":
main()