I am trying to get 2 stepper motors to run at 2 seperate (and changing) speeds on a rpi pico. the pico will also be doing other things (like reading inputs) along side this. the only way I know to control the speed of a motor is using the time.sleep (see code below function between pulses, however this does not work for more than one motor. is there any way to control mltiple outputs without stacking them together in the same loop?
any help would be much appreciated
-Rob
from machine import Pin
import time
step = Pin(16, Pin.OUT)
dire = Pin(17, Pin.OUT)
spr = 200
dire.high()
def turn_motor(steps, delay):
while True:
for i in range(steps):
step.high()
time.sleep(delay)
step.low()
time.sleep(delay)
time.sleep(.5)
dire.low()
for i in range(steps):
step.high()
time.sleep(delay)
step.low()
time.sleep(delay)
time.sleep(.5)
dire.high()
rpm = 70
delay = (rpm/60)/spr
steps = spr*8
turn_motor(steps, delay)
any help would be much appreciated
-Rob
from machine import Pin
import time
step = Pin(16, Pin.OUT)
dire = Pin(17, Pin.OUT)
spr = 200
dire.high()
def turn_motor(steps, delay):
while True:
for i in range(steps):
step.high()
time.sleep(delay)
step.low()
time.sleep(delay)
time.sleep(.5)
dire.low()
for i in range(steps):
step.high()
time.sleep(delay)
step.low()
time.sleep(delay)
time.sleep(.5)
dire.high()
rpm = 70
delay = (rpm/60)/spr
steps = spr*8
turn_motor(steps, delay)