code.py
 1  # SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
 2  #
 3  # SPDX-License-Identifier: MIT
 4  
 5  """
 6  Use PWM to fade an LED up and down using the potentiometer value as the duty cycle.
 7  
 8  REQUIRED HARDWARE:
 9  * potentiometer on pin GP26.
10  * LED on pin GP14.
11  """
12  import board
13  import analogio
14  import pwmio
15  
16  potentiometer = analogio.AnalogIn(board.GP26)
17  led = pwmio.PWMOut(board.GP14, frequency=1000)
18  
19  while True:
20      led.duty_cycle = potentiometer.value