from machine import Pin, ADC
from utime import sleep
# Pin moteur pas à pas
a = Pin(13, Pin.OUT)
b = Pin(12, Pin.OUT)
c = Pin(11, Pin.OUT)
d = Pin(10, Pin.OUT)
react = 0.05
# Pin joystick
xAxis = ADC(Pin(26))
yAxis = ADC(Pin(27))
click = Pin(22, Pin.IN, Pin.PULL_UP)
tr = True
while tr:
sleep(0.01)
# JOYSTICK
xValue = xAxis.read_u16()
yValue = yAxis.read_u16()
tir = click.value()
print(str(xValue) + ", " + str(yValue) + ", " + str(tir))
print(xValue * react)
if xValue < 32758:
sleep(react)
a.value(1)
b.value(0)
c.value(1)
d.value(0)
sleep(react)
a.value(0)
b.value(1)
c.value(0)
d.value(1)
if xValue > 32759:
sleep(react)
a.value(1)
b.value(0)
c.value(0)
d.value(1)
sleep(react)
a.value(0)
b.value(1)
c.value(1)
d.value(0)