import machine
import time 

from machine import Pin, ADC
from time import sleep

def rangoPot(rango):
    if(rango == 9):
        return 511 
    elif (rango == 10):
         return 1023
    elif(rango == 11):
        return 2047
    else:
        return 4095

led = Pin(4,Pin.OUT)
pot = ADC(Pin(34))
rango = 9
pot.width(rango) 9,10,11,12

aux = rangoPot(rango)

while True:
    valor = pot.read()
    if(valor != 0):
        tiempo = (valor*2)/aux
    else:
        tiempo  = 0.1

    print(tiempo)

    led.value(1)
    sleep(tiempo)
    led.value(0)
    sleep(tiempo)