# lab13_Analog input-output.py
from machine import Pin, ADC, PWM
import time
pot = ADC(Pin(34))
pot.atten(ADC.ATTN_11DB) # read voltage from 0 to 3.3 V.
pot.width(ADC.WIDTH_10BIT) # readings with 10 bit resolution (from 0 to 1023) defual 12 bit (0-4095)
freqency = 10000 # set PWM frequency from 1Hz to 40MHz
led_PWM = PWM(Pin(18), freqency)
while True:
value_pot = pot.read()
print(value_pot)
led_PWM.duty(value_pot)
print(value_pot)
time.sleep(0.1)