-
Notifications
You must be signed in to change notification settings - Fork 3
/
lockbox.py
67 lines (52 loc) · 1.14 KB
/
lockbox.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
### imports ###
from sense_hat import SenseHat
from time import sleep
### variables ###
unlocked1 = False
unlocked2 = False
unlocked3 = False
unlocked4 = False
sh = SenseHat()
e = (0,0,0)
r = (255,0,0)
g = (0,255,0)
w = (255,255,255)
locked_screen = [
e,e,e,e,e,e,e,e,
e,e,e,w,w,e,e,e,
e,e,w,e,e,w,e,e,
e,e,w,e,e,w,e,e,
e,e,r,r,r,r,e,e,
e,e,r,r,r,r,e,e,
e,e,r,r,r,r,e,e,
e,e,e,e,e,e,e,e
]
unlocked_screen = [
e,e,e,e,e,e,e,e,
e,e,e,e,e,w,w,e,
e,e,e,e,w,e,e,w,
e,e,e,e,w,e,e,w,
e,e,g,g,g,g,e,e,
e,e,g,g,g,g,e,e,
e,e,g,g,g,g,e,e,
e,e,e,e,e,e,e,e
]
sh.set_pixels(locked_screen)
### unlock function ###
def unlock():
"""unlocking function"""
sh.set_pixels(unlocked_screen)
sleep(2)
sh.show_message("You have unlocked it!!")
### locks ###
while True:
if round(sh.get_humidity()) >= 50:
unlocked1 = True
if unlocked1 == True and round(int(sh.get_compass())):
unlocked2 = True
if unlocked2 == True and round(sh.get_temperature()) >= 26:
unlocked3 = True
if unlocked3 == True and round(int(sh.get_accelerometer()['roll'])) >= 57:
unlocked4 = True
unlock()
quit()