Advertisement
Guest User

Untitled

a guest
Apr 12th, 2023
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.90 KB | None | 0 0
  1. import time
  2. import RPi.GPIO as GPIO
  3.  
  4. class Lock:
  5.     def __init__(self, passphrase):
  6.         self.passphrase = passphrase
  7.         GPIO.setup(12, GPIO.OUT)
  8.         self.stack = []
  9.  
  10.  
  11.     def unlock(self):
  12.         GPIO.output(12, GPIO.HIGH)
  13.         print("==================== unlocked ====================")
  14.         time.sleep(5)
  15.         self.lock()
  16.  
  17.     def lock(self):
  18.         GPIO.output(12, GPIO.LOW)
  19.         print("==================== locked ====================")
  20.  
  21.     def addDigit(self, digit):
  22.         self.stack.append(digit)
  23.  
  24.     def receiveOk(self):
  25.         passcode = ""
  26.         passcode = passcode.join(self.stack)
  27.         print("Passcode is " + passcode)
  28.         if(passcode == self.passphrase):
  29.             self.unlock()
  30.         else:
  31.             print("Wrong passcode")
  32.  
  33.         self.stack = []
  34.  
  35.     def receiveReset(self):
  36.         print("Resetting")
  37.         self.stack = []
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement