Code: Select all
from machine import pin
delay=50
# define code initial values (pin1,oin2,pin3,pin4,delay)
def set_stepper(v,y,x,z,delay) :
global delay
a=Pin(str(v), mode = Pin.OUT)
b=Pin(str(x), mode = Pin.OUT)
c=Pin(str(y), mode = Pin.OUT)
d=Pin(str(z), mode = Pin.OUT)
global pins
pins=[a,b,c,d]
def sequence(*pattern):
for x in range(5):
pins[x].value(pattern[x])
def step(steps) :
fullsteps = ((0,1,0,1), (0,1,1,0), (1,0,1,0), (1,0,0,1))
for i in range(0, steps):
#looping the the whole sequence once for each step
for pattern in fullsteps:
sequence(*pattern)
time.sleep_ms(delay)
def h_step(steps) :
halfsteps = ((0,1,0,1), (0,1,0,0), (0,1,1,0), (0,0,1,0),(1,0,1,0), (1,0,0,0), (1,0,0,1), (0,0,0,1))
#looping the the whole sequence once for each step
for i in range(0, steps):
for pattern in halfsteps:
sequence(*pattern)
time.sleep_ms(delay)
#def distance() :
# define the number of steps needed to complete the whole axe
#def callibrate(length,end_pin) :
#def dis_fix() :
set_stepper(P16,P17,P18,P19,50)
step(100000000000000000)