-
Notifications
You must be signed in to change notification settings - Fork 1
/
lock.py
38 lines (29 loc) · 929 Bytes
/
lock.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
import time
import RPi.GPIO as GPIO
class Lock:
def __init__(self, passphrase):
self.passphrase = passphrase
GPIO.setup(12, GPIO.OUT)
self.stack = []
def unlock(self):
GPIO.output(12, GPIO.HIGH)
print("==================== unlocked ====================")
time.sleep(5)
self.lock()
def lock(self):
GPIO.output(12, GPIO.LOW)
print("==================== locked ====================")
def addDigit(self, digit):
self.stack.append(digit)
def receiveOk(self):
passcode = ""
passcode = passcode.join(self.stack)
print("Passcode is " + passcode)
if(passcode == self.passphrase):
self.unlock()
else:
print("Wrong passcode")
self.stack = []
def receiveReset(self):
print("Resetting")
self.stack = []