Advertisement
pperez_awto

Untitled

Apr 26th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. import RPi.GPIO as GPIO
  2. from time import sleep
  3. from requests import get
  4.  
  5. def main():
  6.     URL = "http://awtosuite.pro/RaspAPI/unlock_box?id=1"
  7.     PAUSE_IN_SECONDS = 1
  8.  
  9.     while True:
  10.         try:
  11.             response = get(URL)
  12.  
  13.             print(response.text)
  14.    
  15.             if(response.text == "200,1"):
  16.                 unlock()
  17.                 print("unlock")
  18.        
  19.             sleep(PAUSE_IN_SECONDS)
  20.         except:
  21.             print("error")
  22.  
  23. def unlock():
  24.     GPIO.setmode(GPIO.BCM)
  25.     GPIO.setup(18, GPIO.OUT)
  26.     GPIO.output(18,GPIO.HIGH)
  27.     sleep(2)
  28.     GPIO.output(18,GPIO.LOW)
  29.     sleep(2)
  30.     GPIO.output(18,GPIO.HIGH)
  31.  
  32. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement