-
Notifications
You must be signed in to change notification settings - Fork 0
/
w.py
53 lines (45 loc) · 1.43 KB
/
w.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
#!/usr/bin/python
from Adafruit_PWM_Servo_Driver import PWM
import time
# ===========================================================================
# Example Code
# ===========================================================================
# Initialise the PWM device using the default address.
# bmp = PWM(0x40, debug=True)
pwm = PWM(0x40, debug=True)
servoMin = 150 # Min pulse length out of 4096
servoMinn = 1 # Min pulse length out of 4096
servoMax = 600 # Max pulse length out of 4096
servoMid = 375
servoMaxx = 740
servoMaxxx = 760
y = "yes"
m = 375
def setServoPulse(channel, pulse):
pulseLength = 1000000 # 1,000,000 us per second
pulseLength /= 60 # 60 Hz
print "%d us per period" % pulseLength
pulseLength /= 4096 # 12 bits of resolution
print "%d us per bit" % pulseLength
pulse *= 1000
pulse /= pulseLength
pwm.setPWM(channel, 0, pulse)
pwm.setPWMFreq(60) # Set frequency to 60 Hz
while y != "no":
# oldcomment Change speed of continuous servo on channel O
m = raw_input("Now what? >>")
if m != "stop":
pwm.setPWM(1, 0, int(m))
# elif m == "0":
# pwm.setPWM(1, 0, servoMinn)
# elif m == "3":
# pwm.setPWM(1, 0, servoMax)
# elif m == "2":
# pwm.setPWM(1, 0, 375)
# elif m == "4":
# pwm.setPWM(1, 0, servoMaxx)
# elif m == "5":
# pwm.setPWM(1, 0, servoMaxxx)
else:
y = "no"
print "murder she wrote"