Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import RPi.GPIO as GPIO
- import urllib.request
- import urllib.response
- import urllib.error
- GPIO.setmode (GPIO.BCM)
- GPIO.setwarnings(False)
- GPIO.setup(40,GPIO.OUT)
- true = 1
- while(true):
- try:
- response = urllib.request.urlopen('xxxxxxxxxx')
- status = response.read()
- except urllib.error.HTTPError as e:
- print (e.code)
- except urllib.error.HTTPError as e:
- print (e.args)
- print (status)
- if status=='ON':
- print ("setting GPIO 40 ")
- GPIO.output(40,True)
- elif status=='OFF':
- GPIO.output(40,False)
Add Comment
Please, Sign In to add comment