66 lines
1.7 KiB
Python
66 lines
1.7 KiB
Python
|
#!/usr/bin/env python3
|
||
|
'''
|
||
|
电机调度器
|
||
|
'''
|
||
|
from RPi import GPIO
|
||
|
from worker import Motor, ENAMotor
|
||
|
from time import sleep
|
||
|
|
||
|
GPIO.setmode(GPIO.BCM)
|
||
|
|
||
|
# carousel = ENAMotor(20, 21, 1.8, 32, 26)
|
||
|
# elevator = Motor(19, 16, 18, 16)
|
||
|
# slide_degree = ENAMotor(12, 13, 1.8, 32, 6)
|
||
|
# slide_width = Motor(0, 5, 0.18, 16)
|
||
|
# recycleh = ENAMotor(7, 1, 1.8, 32, 8)
|
||
|
# recyclev = ENAMotor(9, 11, 1.8, 32, 10)
|
||
|
|
||
|
# '''旋转木马可能卡住,只转90度可能没有问题。'''
|
||
|
# '''旋转木马逆时针旋转90度'''
|
||
|
# carousel.turn_degree(90, GPIO.LOW)
|
||
|
|
||
|
# # '''旋转木马顺时针旋转90度'''
|
||
|
# # carousel.turn_degree(90, GPIO.HIGH)
|
||
|
|
||
|
# '''电梯:药片几乎下不去,下去之后下落速度特别快,直接弹飞了。'''
|
||
|
# '''电梯下降2.7CM'''
|
||
|
# elevator.turn_degree(7200 * 2.8, GPIO.HIGH)
|
||
|
# '''sleep'''
|
||
|
# sleep(1)
|
||
|
# '''电梯上升2.7CM'''
|
||
|
# elevator.turn_degree(7200 * 2.8, GPIO.LOW)
|
||
|
|
||
|
# '''宽度现在不能调,等电阻来了之后再弄。'''
|
||
|
# # slide_width.turn_degree(360, GPIO.HIGH)
|
||
|
# # sleep(1)
|
||
|
# # slide_width.turn_degree(360, GPIO.LOW)
|
||
|
|
||
|
# '''滑梯角度抬升'''
|
||
|
# slide_degree.turn_degree(360 * 2, GPIO.HIGH)
|
||
|
# sleep(2)
|
||
|
|
||
|
# # '''不考虑回收'''
|
||
|
# # slide_degree.turn_degree(360 * 2, GPIO.LOW)
|
||
|
|
||
|
# '''考虑回收'''
|
||
|
# slide_degree.turn_degree(360 * 4, GPIO.LOW)
|
||
|
# sleep(2)
|
||
|
# slide_degree.turn_degree(360 * 2, GPIO.HIGH)
|
||
|
|
||
|
|
||
|
# '''回收部分:废了'''
|
||
|
# # '''回收上升'''
|
||
|
# # recyclev.turn_degree(360 * 42, GPIO.HIGH)
|
||
|
# # '''回收伸入'''
|
||
|
# # recycleh.turn_degree(360 * 4.5, GPIO.HIGH)
|
||
|
# # sleep(2)
|
||
|
# # recycleh.turn_degree(360 * 4.5, GPIO.LOW)
|
||
|
# # '''回收下降'''
|
||
|
# # recyclev.turn_degree(360 * 42, GPIO.LOW)
|
||
|
|
||
|
GPIO.setup(4, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
|
||
|
GPIO.wait_for_edge(4, GPIO.FALLING)
|
||
|
print("catched falling pill.")
|
||
|
|
||
|
GPIO.cleanup()
|