-
Notifications
You must be signed in to change notification settings - Fork 2
/
roll_test.py
61 lines (55 loc) · 1.41 KB
/
roll_test.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
53
54
55
56
57
58
59
60
61
import smbus
import mraa
import time
import math
import numpy as np
import IMU
RAD_TO_DEG = 57.29578
M_PI = 3.14159265358979323846
Apwm=Bpwm=Cpwm=Dpwm=Adir=Bdir=Cdir=Ddir=mode=0
output = [Apwm,Bpwm,Cpwm,Dpwm,Adir,Bdir,Cdir,Ddir,mode]
Pin = [14,20,0,21,36,48,47,32,46] #PWM for GP13,GP12,GP182,GP183 Gpio for GP14,GP15,GP49,GP48,GP47
for x in xrange(0,4):
output[x] = mraa.Pwm(Pin[x])
output[x].period_us(700)
output[x].enable(True)
print x, output[x]
for x in xrange(4,9):
output[x] = mraa.Gpio(Pin[x])
output[x].dir(mraa.DIR_OUT)
print x,output[x]
output[8].write(1) #Set Mode to high
def rampup():
x=0
while x <= 1:
output[0].write(x)
output[1].write(x)
output[2].write(x)
output[3].write(x)
time.sleep(.1)
x+=.05
print x
def rampdown():
x=1
while x >= 0:
output[0].write(x)
output[1].write(x)
output[2].write(x)
output[3].write(x)
time.sleep(.1)
x-=.05
print x
while True:
output[4].write(1)
output[5].write(1)
output[6].write(1)
output[7].write(1)
print output[4]
rampup()
rampdown()
output[4].write(0)
output[5].write(0)
output[6].write(0)
output[7].write(0)
rampup()
rampdown()