-
Notifications
You must be signed in to change notification settings - Fork 2
/
arm_driver.py
52 lines (44 loc) · 1.21 KB
/
arm_driver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import board
import digitalio
from time import sleep
from queue import Queue
from threading import Thread
class ArmDriver():
def __init__(self):
# self.q = Queue()
# self.t = Thread(target=self.consume)
# self.t.start()
self.ARM = digitalio.DigitalInOut(board.D26)
self.ARM.direction = digitalio.Direction.OUTPUT
self.ARM.value = False
self.FAN = digitalio.DigitalInOut(board.D19)
self.FAN.direction = digitalio.Direction.OUTPUT
self.FAN.value = False
self.down()
def pickup(self):
# turn on fan
self.FAN.value = True
# lower arm
self.ARM.value = False
# wait for fan to hit full speed and pickup butt
sleep(8)
# raise arm
self.ARM.value = True
sleep(3)
# turn off fan
self.FAN.value = False
# wait for butt to fall
sleep(6)
# return arm to prev state
if self.state == 'up':
self.up()
else:
self.down()
def up(self):
self.ARM.value = True
sleep(3)
self.state = 'up'
def down(self):
self.ARM.value = False
sleep(3)
self.state = 'down'