from machine import Pin
from utime import sleep_ms
St_x = Pin (13,Pin.OUT)
DIR_x = Pin (12,Pin.OUT)
St_y = Pin (27,Pin.OUT)
DIR_y = Pin (26,Pin.OUT)
def Move(x1,y1,x2,y2):
x = x2-x1
y = y2-y1
print("X=",x,"Y=",y)
if x >= 0:
step_x = x
D1_x = 1
else:
step_x = x*-1
D1_x = 0
if y >= 0:
step_y = y
D1_y = 1
else:
step_y = y*-1
D1_y = 0
print("step X =",step_x,"step Y =",step_y)
print("Dir x",Di_x,"Dir Y",Di_y)
if step_x > step_y:
D_X = 500
D_Y=int(round((step_x*500)/step_y,0))
elif step_x < step_y:
D_Y = 500
D_X=int(round((step_y*500)/step_y,0))
else :
D_X = 500
D_Y = 500
print("X=",x,"Y=",y)
print("step X=",step_x,"step Y=",step_y)
print("DIR X=",Di_x,"DIR Y=",Di_y)
print("deley X=",D_X,"deley Y=",D_Y,)
Move(0,0,4,4)
Move(4,4,10,20)
Move(10,20,20,10)
#if D1_x == 1:
# DIR_x.on()
#else:
# DIR_x.off()
#for i in range(step_x):
# ST_x.on()
# sleep_ms(D_x)
# ST_x.off()
# sleep_ms(D_x)
#def Stepper(di, st, time):
# if di == 0:
# DIR.off()
# else:
# DIR.on()
# for x in range(st):
# Step.on()
# sleep_ms(time)
# Step.off()
# sleep_ms(time)
#Stepper(0, 32, 20)