Chapter 16 Stepping Motor
Subfunction moveSteps (direction, ms, steps) is used to specific cycle number of stepping motor.
def moveSteps(direction, ms, steps):
for i in range(steps):
moveOnePeriod(direction, ms)
Subfunction motorStop () is used to stop the stepping motor.
def motorStop():
for i in range(0,4,1):
GPIO.output(motorPins[i],GPIO.LOW)
Finally, in the while cycle of main function, rotate one circle clockwise, and then one circle anticlockwise.
According to the previous knowledge of the stepping motor, it can be known that the stepping motor rotation
for one circle requires 2048 steps, that is, 2048/4=512 cycle.
w hile Tr ue:
moveSteps(1,3,512) #rotating 360° clockwise, a total of 2048 steps in a
circle, namely, 512 cycles.
time.sleep(0.5)
moveSteps(0,3,512) #rotating 360° anticlockwise
time.sleep(0.5)