Skip to content

Instantly share code, notes, and snippets.

@reactorcoremeltdown
Created January 16, 2017 21:50
Show Gist options
  • Save reactorcoremeltdown/760e66975e06849a612516b0da9151ba to your computer and use it in GitHub Desktop.
Save reactorcoremeltdown/760e66975e06849a612516b0da9151ba to your computer and use it in GitHub Desktop.
#!/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