#write a microPython script to control the brightness of the led to connected to gpio14 with respect to position of the pot-meter which is connect to gpio15
from machine import Pin, PWM, ADC
from time import sleep
frequency = 5000
led = PWM(Pin(14), frequency)
pot = ADC(Pin(15))
pot.width(ADC.WIDTH_10BIT)
pot.atten(ADC.ATTN_11DB) #ADC.ATTN_0DB = 1.2V, ADC.ATTN_2.5DB = 1.5V, ADC.ATTN_6DB = 2.0V, ADC.ATTN_11DB = 3.3V
while True:
pot_value = pot.read()
print(pot_value)
led.duty(pot_value)
# if pot_value < 15:
# led.duty(0)
# else:
# led.duty(pot_value)
sleep(0.1)