我正在玩一个NEM17步进电机在一个树莓皮4使用Python 3.7.3和A4988步进电机驱动器。我运行下面的代码,它工作良好,但在代码完成后,步进电机继续以一种有点零散的方式转动。如何让它在完成代码后停止?我在下面包含了我正在使用的代码
# import the library
from RpiMotorLib import RpiMotorLib
#define GPIO pins
GPIO_pins = (17, 27, 22) # Microstep Resolution MS1-MS3 -> GPIO Pin
direction= 24 # Direction -> GPIO Pin
step = 23 # Step -> GPIO Pin
# Declare an named instance of class pass GPIO pins numbers
mymotortest = RpiMotorLib.A4988Nema(direction, step, GPIO_pins, "A4988")
# call the function, pass the arguments
mymotortest.motor_go(False, "Half" , 500, .001, False, .05)
# good practise to cleanup GPIO at some point before exit
GPIO.cleanup()```
P.S I was wondering what would be the best library or way to control a stepper motor? As in, is this the best library to be using or are there better and more precise methods in doing so.
Thank you
也许GPIO.cleanup会将GPIO输出置于未定义的浮动状态。 在GPIO.cleanup之前,尝试将A4988置于睡眠模式A4988 pdf
相关问题 更多 >
编程相关推荐