1 Star 0 Fork 0

杨雪元/raspberrypi_cookbook_ed2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
stepper_hat.py 603 Bytes
一键复制 编辑 原始数据 按行查看 历史
Simon Monk 提交于 2016-02-05 12:16 . added lots of code
from Adafruit_MotorHAT import Adafruit_MotorHAT
import time
HAT = Adafruit_MotorHAT
stepper_hat = Adafruit_MotorHAT()
stepper = stepper_hat.getStepper(200, 1) # 200 steps/rev, port 1 (M1, M2)
try:
while True:
speed = input("Enter stepper speed (rpm) ")
stepper.setSpeed(speed)
steps_forward = input("Steps forward ")
stepper.step(steps_forward, HAT.FORWARD, HAT.SINGLE)
steps_forward = input("Steps reverse ")
stepper.step(steps_forward, HAT.BACKWARD, HAT.SINGLE)
finally:
print("cleaning up")
stepper_hat.getMotor(1).run(HAT.RELEASE)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yang_xueyuan/raspberrypi_cookbook_ed2.git
git@gitee.com:yang_xueyuan/raspberrypi_cookbook_ed2.git
yang_xueyuan
raspberrypi_cookbook_ed2
raspberrypi_cookbook_ed2
master

搜索帮助