SHARE
TWEET

Kont1

a guest Jan 24th, 2020 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python
  2.  
  3. import RPi.GPIO as GPIO
  4. import time
  5. import urllib
  6. import urllib2
  7.  
  8. sensor = 17
  9. sensor = 18
  10. sensor = 22
  11. sensor = 23
  12. sensor = 24
  13. sensor = 27
  14.  
  15. GPIO.setmode(GPIO.BCM)
  16. GPIO.setup(sensor, GPIO.IN, pull_up_down=GPIO.PUD_UP)
  17.  
  18. previous_state = False
  19. current_state = False
  20.  
  21. while True:
  22.     time.sleep(0.1)
  23.     previous_state = current_state
  24.     current_state = GPIO.input(sensor)
  25.     if current_state != previous_state:
  26.      if current_state:
  27.       httpresponse = urllib.urlopen ("http://192.168.0.10:8084/json.htm?type=command&param=switchlight&idx=52, 53, 54, 55, 56, 57&switchcmd=On")
  28.      else:
  29.       httpresponse = urllib.urlopen ("http://192.168.0.10:8084/json.htm?type=command&param=switchlight&idx=52, 53, 54, 55, 56, 57&switchcmd=Off")
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top