from machine import Pin
from time import sleep
from machine import ADC
ledV = Pin(0, Pin.OUT)
sensorH = 28
botG = Pin(17, Pin.IN)
botR = Pin (16, Pin.IN)
sensor = ADC(sensorH)
freq = 100
P = (100/freq)
TL = 0
while True:
contador = 0
sensor_value= sensor.read_u16()
TH = (sensor_value/16)/4095
duty = TH/P
sleep(0.5)
if(botG.value()==0):
ledV.on
sleep(0.5)
elif(botR.value()==0):
ledV.off
sleep(0.5)
for contador in range (0, TH):
ledV.on()
sleep(0.01)
for contador in range (TH, P):
ledV.off()
sleep(0.01)
print("Micropython:", sensor_value, "Raspberry Pico:", int(sensor_value/16))
print(TH)