#Write a Micropython script to 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_10BIT) #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()
print(pot_value)
led.duty(pot_value)
sleep(0.1)