#Read the analog data provided by POT connected to GPIO34 and print on shell every o.1 sec
from machine import Pin, ADC, PWM
from time import sleep
POT = ADC(Pin(34))
frequency = 5000
led = PWM(Pin(22), frequency)
POT.width(ADC.WIDTH_12BIT) #range: 0-1023 (Since, 12BIT is the default one) pot.atten(ADC.ATTN_11DB) #Full range: 3.3v
POT.atten(ADC.ATTN_11DB)#Specifying the voltage of the Analog sensor
while True:
pot_value = POT.read()
y = pot_value//4
print(y)
led.duty(y)
sleep(0.1)