Created
January 16, 2017 21:50
-
-
Save reactorcoremeltdown/760e66975e06849a612516b0da9151ba to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
import serial | |
import time | |
import urllib2 | |
turn_on = '$KE,REL,1,1\r\n' | |
turn_off = '$KE,REL,1,0\r\n' | |
state = False | |
url = 'http://wasteland.dev.it-the-drote.tk/tmp/led.state' | |
ser = serial.Serial('/dev/cu.usbmodem5d21', 9600) | |
while True: | |
response = urllib2.urlopen(url) | |
msg = response.read() | |
print msg | |
if msg == 'off\n': | |
ser.write(turn_off) | |
elif msg == 'on\n': | |
ser.write(turn_on) | |
time.sleep(1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment