Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import RPi.GPIO as GPIO
- import webbrowser
- import time
- import RPi.GPIO as GPIO
- GPIO.setwarnings(False)
- GPIO.setmode(GPIO.BCM)
- onPin = 27
- offPin = 22
- state1 = 0
- state2 = 0
- GPIO.setup(onPin,GPIO.IN)
- GPIO.setup(offPin,GPIO.IN)
- while True:
- if GPIO.input(onPin) == GPIO.HIGH:
- if state1 == 0:
- print("ON")
- webbrowser.open('http://192.168.48.251/H')
- state1 = 1
- time.sleep(0.5)
- elif GPIO.input(onPin) == GPIO.LOW:
- if state1 == 1:
- state1 = 0
- if GPIO.input(offPin) == GPIO.HIGH:
- if state2 == 0:
- print("OFF")
- webbrowser.open('http://192.168.48.251/L')
- state2=1
- time.sleep(0.5)
- elif GPIO.input(offPin) == GPIO.LOW:
- if state2 == 1:
- state2 = 0
Advertisement
Add Comment
Please, Sign In to add comment