-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMotionSensor.py
More file actions
executable file
·85 lines (82 loc) · 2.86 KB
/
MotionSensor.py
File metadata and controls
executable file
·85 lines (82 loc) · 2.86 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
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
''' Note : This code cannot work using the Android application as the sensor needs a VOUT port to be used
To make both the motion sensor and the Android Application work together use a level shifter and soilder
the ultrasonic sensor to the 3.3V port'''
import Ambience
import board
from hcsr04 import HCSR04
trig = board.A4
echo = board.A5
with HCSR04(trig, echo) as sonar:
try:
while True:
distance = sonar.dist_cm
if(distance <= 20):
'# top flash'''
for j in range(616)
strip[j]=(0, 0, 255)
strip.show()
for j in range(616)
strip[j]=(0, 0, 0)
strip.show()
for j in range(616)
strip[j]=(0, 0, 255)
strip.show()
for j in range(616)
strip[j]=(0, 0, 0)
strip.show()
'# top and bottom flash'''
for j in range(616)
strip[j]=(0, 0, 255)
strip3[j]=(0, 0, 255)
strip.show()
strip3.show()
for j in range(616)
strip[j]=(0, 0, 0)
strip3[j]=(0, 0, 0)
strip.show()
strip3.show()
for j in range(616)
strip[j]=(0, 0, 255)
strip3[j]=(0, 0, 255)
strip.show()
strip3.show()
for j in range(616)
strip[j]=(0, 0, 0)
strip3[j]=(0, 0, 0)
strip.show()
strip3.show()
'everything flashes'''
for j in range(616)
strip[j]=(0, 0, 255)
strip2[j]=(0, 0, 255)
strip3[j]=(0, 0, 255)
strip.show()
strip2.show()
strip3.show()
for j in range(616)
strip[j]=(0, 0, 0)
strip2[j]=(0, 0, 0)
strip3[j]=(0, 0, 0)
strip.show()
strip2.show()
strip3.show()
for j in range(616)
strip[j]=(0, 0, 255)
strip2[j]=(0, 0, 255)
strip3[j]=(0, 0, 255)
strip.show()
strip2.show()
strip3.show()
for j in range(616)
strip[j]=(0, 0, 0)
strip2[j]=(0, 0, 0)
strip3[j]=(0, 0, 0)
strip.show()
strip2.show()
strip3.show()
if (distance >20 and distance <50):
Ambience.AmbienceDark()
if (distance>50 and distance != 716):
Ambience.AmbienceLight()
except KeyboardInterrupt:
pass