-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdcmd.py
More file actions
46 lines (43 loc) · 1.07 KB
/
dcmd.py
File metadata and controls
46 lines (43 loc) · 1.07 KB
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
import pyfirmata
from time import sleep
from math import exp
# don't forget to change the serial port to suit
board = pyfirmata.Arduino('COM8')
time = exp(-200)
rotate = 570
rotations = 2
LOW = 0
HIGE = 1
def root(x):
rot([LOW,LOW,LOW,HIGE],x)
sleep(time)
rot([LOW,LOW,HIGE,HIGE],x)
sleep(time)
rot([LOW,LOW,HIGE,LOW],x)
sleep(time)
rot([LOW,HIGE,HIGE,LOW],x)
sleep(time)
rot([LOW,HIGE,LOW,LOW],x)
sleep(time)
rot([HIGE,HIGE,LOW,LOW],x)
sleep(time)
rot([HIGE,LOW,LOW,LOW],x)
sleep(time)
rot([LOW,LOW,LOW,LOW],x)
sleep(time)
def rot(x,y):
if y:
board.digital[8].write(x[0])
board.digital[9].write(x[1])
board.digital[10].write(x[2])
board.digital[11].write(x[3])
else:
board.digital[11].write(x[-4])
board.digital[10].write(x[-3])
board.digital[9].write(x[-2])
board.digital[8].write(x[-1])
for _ in range(rotations):
for _ in range(rotate):
root(1)
for _ in range(rotate):
root(0)