from machine import Pin
import utime
dir_pins = [14,2]
step_pins = [15,3]
pin_state = Pin.OUT
for pin in dir_pins:
dir_pin = Pin(pin, pin_state)
dir_pin.off()
for pin in step_pins:
step_pin = Pin(pin, pin_state)
step_pin.off()
# # Define pins for a motor
# x_dir_pin = Pin(14, Pin.OUT)
# x_step_pin = Pin(15, Pin.OUT)
# # Define pins for b motor
# y_dir_pin = Pin(6, Pin.OUT)
# y_step_pin = Pin(7, Pin.OUT)
# # Define pins for c motor
# z_dir_pin = Pin(2, Pin.OUT)
# z_step_pin = Pin(3, Pin.OUT)
x = y = z = 0
mm_per_step = 0.314
max_x = 300
max_y = 100
max_z = 20
# x_dir_pin.off()
# y_dir_pin.off()
# z_dir_pin.off()
# x_step_pin.off()
# y_step_pin.off()
# z_step_pin.off()
def rotate_initial(steps, direction, delay):
dir_pin.value(direction)
for _ in range(steps):
step_pin.on()
utime.sleep_ms(delay)
step_pin.off()
utime.sleep_ms(delay)
def rotate_x(steps, direction, delay):
dir_pin.value(direction)
for _ in range(steps):
step_pin.on()
utime.sleep_ms(delay)
step_pin.off()
utime.sleep_ms(delay)
def rotate_z(steps, direction, delay):
dir_pin.value(direction)
for _ in range(steps):
step_pin.on()
utime.sleep_ms(delay)
step_pin.off()
utime.sleep_ms(delay)
rotate_initial(2,1,0)
x = float(input("x = "))
z = float(input("z = "))
move_x = x / mm_per_step
move_y = y / mm_per_step
move_z = z / mm_per_step
print(move_x)
print(move_z)
# Move 200 steps (one rotation) CW over one second
rotate_x(move_x, 1, 5)
rotate_z(move_z, 1, 5)
utime.sleep_ms(500) # Wait half a second
# # Move 200 steps (one rotation) CCW over 400 milliseconds
# rotate_steppers(200, 0, 2)
# utime.sleep_ms(1000) # Wait another second
pico:GP0
pico:GP1
pico:GND.1
pico:GP2
pico:GP3
pico:GP4
pico:GP5
pico:GND.2
pico:GP6
pico:GP7
pico:GP8
pico:GP9
pico:GND.3
pico:GP10
pico:GP11
pico:GP12
pico:GP13
pico:GND.4
pico:GP14
pico:GP15
pico:GP16
pico:GP17
pico:GND.5
pico:GP18
pico:GP19
pico:GP20
pico:GP21
pico:GND.6
pico:GP22
pico:RUN
pico:GP26
pico:GP27
pico:GND.7
pico:GP28
pico:ADC_VREF
pico:3V3
pico:3V3_EN
pico:GND.8
pico:VSYS
pico:VBUS
stepper1:A-
stepper1:A+
stepper1:B+
stepper1:B-
drv1:ENABLE
drv1:MS1
drv1:MS2
drv1:MS3
drv1:RESET
drv1:SLEEP
drv1:STEP
drv1:DIR
drv1:GND.1
drv1:VDD
drv1:1B
drv1:1A
drv1:2A
drv1:2B
drv1:GND.2
drv1:VMOT
drv2:ENABLE
drv2:MS1
drv2:MS2
drv2:MS3
drv2:RESET
drv2:SLEEP
drv2:STEP
drv2:DIR
drv2:GND.1
drv2:VDD
drv2:1B
drv2:1A
drv2:2A
drv2:2B
drv2:GND.2
drv2:VMOT
drv3:ENABLE
drv3:MS1
drv3:MS2
drv3:MS3
drv3:RESET
drv3:SLEEP
drv3:STEP
drv3:DIR
drv3:GND.1
drv3:VDD
drv3:1B
drv3:1A
drv3:2A
drv3:2B
drv3:GND.2
drv3:VMOT
stepper2:A-
stepper2:A+
stepper2:B+
stepper2:B-
stepper3:A-
stepper3:A+
stepper3:B+
stepper3:B-