-
Notifications
You must be signed in to change notification settings - Fork 1
/
features.py
94 lines (85 loc) · 2.65 KB
/
features.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
A = 5
B = 6
C = 13
D = 19
lights = 26
GPIO.setup(A, GPIO.OUT, initial = 0)
GPIO.setup(B, GPIO.OUT, initial = 0)
GPIO.setup(C, GPIO.OUT, initial = 0)
GPIO.setup(D, GPIO.OUT, initial = 0)
GPIO.setup(lights, GPIO.OUT,initial = 0)
GPIO.output(5, GPIO.HIGH)
GPIO.output(6, GPIO.HIGH)
GPIO.output(13, GPIO.HIGH)
GPIO.output(19, GPIO.HIGH)
class motion:
"has functions related to the motion of the lamp"
def reset():
GPIO.output(5, GPIO.HIGH)
GPIO.output(6, GPIO.HIGH)
GPIO.output(13, GPIO.HIGH)
GPIO.output(19, GPIO.HIGH)
def mov(s):
GPIO.setmode(GPIO.BCM)
A = 5
B = 6
C = 13
D = 19
lights = 26
GPIO.setup(A, GPIO.OUT, initial = 0)
GPIO.setup(B, GPIO.OUT, initial = 0)
GPIO.setup(C, GPIO.OUT, initial = 0)
GPIO.setup(D, GPIO.OUT, initial = 0)
GPIO.setup(lights, GPIO.OUT,initial = 0)
#general movement
if s=="F" or s=="f":
GPIO.output(5, GPIO.HIGH)
GPIO.output(6, GPIO.LOW)
GPIO.output(13, GPIO.LOW)
GPIO.output(19, GPIO.LOW)
print("I am bending forward")
time.sleep(3)
return "I am bending forward"
if s=="B" or s=="b":
GPIO.output(6, GPIO.HIGH)
GPIO.output(5, GPIO.LOW)
GPIO.output(13, GPIO.LOW)
GPIO.output(19, GPIO.LOW)
print("I am bending backward")
time.sleep(3)
return "I am bending backward"
if s=="l" or s=="L":
GPIO.output(13, GPIO.HIGH)
GPIO.output(5, GPIO.LOW)
GPIO.output(6, GPIO.LOW)
GPIO.output(19, GPIO.LOW)
print("I am bending left")
time.sleep(3)
return "I am bending left"
if s=="R" or s=="r":
GPIO.output(19, GPIO.HIGH)
GPIO.output(5, GPIO.LOW)
GPIO.output(6, GPIO.LOW)
GPIO.output(13, GPIO.LOW)
print("I am bending Right")
time.sleep(3)
return "I am bending Right"
if s=="t" or s=="T":
GPIO.output(5, GPIO.HIGH)
GPIO.output(6, GPIO.LOW)
GPIO.output(13, GPIO.HIGH)
GPIO.output(19, GPIO.LOW)
time.sleep(3)
return "testing"
def light(glow):
if glow=="on":
GPIO.output(26, GPIO.HIGH)
print("Lights turned on")
return "Lights turned on"
if glow=="off":
GPIO.output(26, GPIO.LOW)
print("Lights turned on")
return "Lights turned on"