earthquakepi.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:earthquakepi 作者: rgrokett 项目源码 文件源码
def motor(mag): # Run Motor
    pulse = 1
    speed = int(mag * 3 + 20)  # Min 20 max 50
    duration = int(10 - mag)    # 2 sec to 20 sec
    sec = 0.1

    p = GPIO.PWM(MOTORPIN, 50)  # channel=MOTORPIN frequency=50Hz
    p.start(0)
    p.ChangeDutyCycle(speed)
    time.sleep(0.1)
    for dc in range(speed, 10, -(duration)):
         p.ChangeDutyCycle(dc)
         time.sleep(pulse)
         pulse = pulse + sec
    p.stop()
    return
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号