from machine import Pin, ADC, PWM
from time import sleep
# POTENCIOMETRO
adc = ADC(Pin(32))
adc.width(ADC.WIDTH_9BIT)
adc.atten(ADC.ATTN_11DB)
# MOTOR
motor=PWM(Pin(18),freq=1000)
dir1=Pin(22,Pin.OUT)
dir2=Pin(23,Pin.OUT)
while(1):
val=adc.read()
if (val <=102):
motor.duty(1023)
dir1.on()
dir2.off()
elif (val <=204):
motor.duty(450)
dir1.on()
dir2.off()
elif (val <=306):
motor.duty(0)
elif (val <=408):
motor.duty(450)
dir1.off()
dir2.on()
elif (val <=512):
motor.duty(1023)
dir1.off()
dir2.on()