# 가변저항
from machine import Pin, PWM, ADC # machine 패키지에서 디지털 I/O를 위한 Pin 모듈, PWM 신호 발생을 위한 PWM 모듈, ADC 사용을 위한 ADC 모듈 불러옴
# 핀 객체 생성
led = PWM(Pin(17)) # LED 22번 핀에 연결
led.freq(1000) # 신호 주기 설정
potentiometer = ADC(27) # 가변저항의 출력은 ADC 0번 채널이기도 한 26번 핀에 연결
# 실제 작동 코드 (while문)
while True:
potentiometer_value = potentiometer.read_u16() # 데이터를 16bit 표현 범위로 가져옴
led.duty_u16(potentiometer_value) # PWM을 발생시킴