-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathaiservo2.py
37 lines (30 loc) · 806 Bytes
/
aiservo2.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
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
GPIO.setup(3, GPIO.OUT)
p = GPIO.PWM(3, 50)
p.start(0)
x=180
d=(x/18)+2
def ser2():
i=5.5
while i<d :
# p.ChangeDutyCycle(0) # turn towards 90 degree
#time.sleep(1) # sleep 1 second
# p.ChangeDutyCycle(0) # turn towards 0 degree
# time.sleep(1) # sleep 1 second
# turn towards 180 degree
time.sleep(0.2) # sleep 1 second
p.ChangeDutyCycle(i) # turn towards 180 degree
i=i+1.5
# while i>2.5:
# time.sleep(0.2) # sleep 1 second
# p.ChangeDutyCycle(i) # turn towards 180 degree
# i=i-0.3
#p.stop()
def ser():
i=12.5
while i>5.5:
time.sleep(0.2) # sleep 1 second
p.ChangeDutyCycle(i) # turn towards 180 degree
i=i-1.5