我最近开始了我的Rpi项目。
我需要一些关于修改我的代码的帮助或建议。在
我有一个(Pi,+easydriver V4.4,+nema 17步进电机)
使用车身控制模块布局
我需要一个间隔为@的无限嵌套循环
# Do some steps.
for i in range(200):#800 == full rotation
stepper.step()
我希望我的步进器步进200步,然后停止0.1秒,然后再步进200步等(无限循环)
easydriver公司:
^{pr2}$在步进器.py在
#!/usr/bin/python
# -*- coding: utf-8 -*-
import easydriver as ed
cw = True
ccw = False
"""
Arguments to pass or set up after creating the instance.
Step GPIO pin number.
Delay between step pulses in seconds.
Direction GPIO pin number.
Microstep 1 GPIO pin number.
Microstep 2 GPIO pin number.
Sleep GPIO pin number. #not in use
Enable GPIO pin number.#not in use
Reset GPIO pin number.#not in use
Name as a string.#not in use
"""
# Create an instance of the easydriver class.
# Not using sleep, enable or reset in this example.
stepper = ed.easydriver(8, 0.001, 11, 18, 22)
# Set motor direction to clockwise.
stepper.set_direction(cw)
# Set the motor to run in 1/8 of a step per pulse.
stepper.set_full_step()
# Do some steps.
for i in range(200):
stepper.step()
# Clean up (just calls GPIO.cleanup() function.)
stepper.finish()
感觉像个傻瓜。。。在我睡觉的时候有异常! 我是这样创建循环的:
相关问题 更多 >
编程相关推荐