Advertisement
safwan092

Untitled

May 19th, 2023
20
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. import drivers
  2. import RPi.GPIO as GPIO
  3. from mfrc522 import SimpleMFRC522
  4. import datetime
  5. import time
  6.  
  7. door = 17
  8. fan = 27
  9. led = 22
  10.  
  11. GPIO.setwarnings(False)
  12. GPIO.setmode(GPIO.BCM)
  13. GPIO.setup(door, GPIO.OUT)
  14. GPIO.setup(fan, GPIO.OUT)
  15. GPIO.setup(led, GPIO.OUT)
  16.  
  17. GPIO.output(door, False)
  18. GPIO.output(fan, False)
  19. GPIO.output(led, False)
  20.  
  21. reader = SimpleMFRC522()
  22. display = drivers.Lcd()
  23. print("Writing to display")
  24. display.lcd_display_string("Door is:", 1)
  25. display.lcd_display_string("Close", 2)
  26. #card id = 149534553138
  27. #tag id = 109407220734
  28.  
  29. while (True):
  30. id = reader.read_id_no_block()
  31. if id != None:
  32. print(id)
  33. TTime = datetime.datetime.now().strftime("%H:%M:%S")
  34. print(TTime)
  35. if (TTime == "03:06:55") or (id == 149534553138) or (id == 109407220734):
  36. display.lcd_clear()
  37. display.lcd_display_string("Door is:", 1)
  38. display.lcd_display_string("Open", 2)
  39. #open Door
  40. GPIO.output(door, True)
  41. #wait for 10 seconds
  42. time.sleep(10)
  43. GPIO.output(door, False)
  44. if (id != None) and (TTime != "03:06:55"):
  45. display.lcd_display_string("Close", 2)
  46. id = "000"
  47. print(id)
  48. if (TTime == "03:07:55"):
  49. display.lcd_clear()
  50. display.lcd_display_string("Door is:", 1)
  51. display.lcd_display_string("Close", 2)
  52. #close Door
  53. GPIO.output(door, False)
  54. #wait for 1 seconds
  55. time.sleep(1)
  56.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement