179
Chapter 16 Stepping Motor
time
.
sleep
(
ms
*
0.001
)
Subfunction
moveSteps
(direction, ms, steps) is used to specific cycle number of stepping motor.
d e f
moveSteps
(
direction
,
ms
,
steps
) :
f o r
i
i n
range
(
steps
):
moveOnePeriod
(
direction
,
ms
)
Subfunction
motorStop
() is used to stop the stepping motor.
d e f
motorStop
():
f o r
i
i n
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 h ile
T r 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
)
Summary of Contents for Ultimate Starter Kit
Page 1: ...Free your innovation Freenove is an open source electronics platform www freenove com ...
Page 117: ...117 Chapter 9 Potentiometer RGBLED www freenove com support freenove com Hardware connection ...
Page 155: ...155 Chapter 14 Relay Motor www freenove com support freenove com Hardware connection OFF 3 3V ...
Page 173: ...173 Chapter 16 Stepping Motor www freenove com support freenove com Hardware connection ...
Page 239: ...239 Chapter 22 Matrix Keypad www freenove com support freenove com Circuit Schematic diagram ...
Page 240: ...Chapter 22 Matrix Keypad 240 www freenove com support freenove com Hardware connection ...