Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from machine import ADC
- from machine import Pin
- from time import sleep
- #Analog input pins
- joyx = ADC(Pin(39))
- joyy = ADC(Pin(36))
- #Analog input complete range
- joyx.atten(ADC.ATTN_11DB)
- joyy.atten(ADC.ATTN_11DB)
- #output pins
- ain1 = Pin(12, Pin.OUT)
- ain2 = Pin(13, Pin.OUT)
- bin1 = Pin(18, Pin.OUT)
- bin2 = Pin(19, Pin.OUT)
- while True:
- if joyx.read() < 1500:
- ain1.off()
- ain2.on()
- elif joyx.read() > 2500:
- ain2.off()
- ain1.on()
- else:
- ain1.off()
- ain2.off()
- if joyy.read() < 1500:
- bin1.on()
- bin2.off()
- elif joyy.read() > 2500:
- bin1.off()
- bin2.on()
- else:
- bin1.off()
- bin2.off()
- x_value = joyx.read()
- y_value = joyy.read()
- print("El eje x: ",x_value)
- sleep(1)
- print("El eje y: ",y_value)
Add Comment
Please, Sign In to add comment