Created
February 8, 2014 01:32
-
-
Save lsongdev/8875293 to your computer and use it in GitHub Desktop.
Raspberry Pi and Relay
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import RPi.GPIO as GPIO | |
import web | |
PIN = 7 | |
# to use Raspberry Pi board pin numbers | |
GPIO.setmode(GPIO.BOARD) | |
# set up GPIO output channel | |
GPIO.setup(PIN, GPIO.OUT) | |
urls = ( | |
'/', 'index', | |
'/open','open', | |
'/close', 'close' | |
) | |
app = web.application(urls, globals()) | |
class index: | |
def GET(self): | |
return '<a href="/open" >Open</a><a href="/close">Close</a>' | |
class open: | |
def GET(self): | |
GPIO.output(PIN,GPIO.LOW) | |
return 'open' | |
class close: | |
def GET(self): | |
GPIO.output(PIN,GPIO.HIGH) | |
return 'close' | |
if __name__ == "__main__": | |
app.run() | |
GPIO.cleanup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment