Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import RPi.GPIO as GPIO
- import time
- import urllib
- import urllib2
- sensor = 17
- sensor = 18
- sensor = 22
- sensor = 23
- sensor = 24
- sensor = 27
- GPIO.setmode(GPIO.BCM)
- GPIO.setup(sensor, GPIO.IN, pull_up_down=GPIO.PUD_UP)
- previous_state = False
- current_state = False
- while True:
- time.sleep(0.1)
- previous_state = current_state
- current_state = GPIO.input(sensor)
- if current_state != previous_state:
- if current_state:
- httpresponse = urllib.urlopen ("http://192.168.0.10:8084/json.htm?type=command¶m=switchlight&idx=52, 53, 54, 55, 56, 57&switchcmd=On")
- else:
- httpresponse = urllib.urlopen ("http://192.168.0.10:8084/json.htm?type=command¶m=switchlight&idx=52, 53, 54, 55, 56, 57&switchcmd=Off")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement