EasyManua.ls Logo

Freenove Ultimate Starter Kit - Page 179

Freenove Ultimate Starter Kit
286 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
179
Chapter 16 Stepping Motor
www.freenove.com
support@freenove.com
time.sleep(ms*0.001)
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)

Table of Contents