Guest User

Untitled

a guest
May 25th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. import RPi.GPIO as GPIO
  2. import urllib.request
  3. import urllib.response
  4. import urllib.error
  5. GPIO.setmode (GPIO.BCM)
  6. GPIO.setwarnings(False)
  7. GPIO.setup(40,GPIO.OUT)
  8. true = 1
  9. while(true):
  10. try:
  11. response = urllib.request.urlopen('xxxxxxxxxx')
  12. status = response.read()
  13. except urllib.error.HTTPError as e:
  14. print (e.code)
  15.  
  16. except urllib.error.HTTPError as e:
  17. print (e.args)
  18.  
  19. print (status)
  20. if status=='ON':
  21. print ("setting GPIO 40 ")
  22. GPIO.output(40,True)
  23. elif status=='OFF':
  24. GPIO.output(40,False)
Add Comment
Please, Sign In to add comment