Skip to content

Instantly share code, notes, and snippets.

@lucaspolo
Created September 7, 2014 23:27
Show Gist options
  • Save lucaspolo/8937379e1c32c9567fb2 to your computer and use it in GitHub Desktop.
Save lucaspolo/8937379e1c32c9567fb2 to your computer and use it in GitHub Desktop.
Servidor que manda simples comandos para a porta serial, podendo controlar um Arduino.
#!/usr/bin/env python
import web, serial
urls = (
'/arduino', 'arduino'
)
app = web.application(urls, globals())
ligado = 0
ser = serial.Serial("/dev/tty.usbmodem14121", 9600);
class arduino:
def GET(self):
global ligado
print 'metodo chamado: '
if ligado == 0:
ser.write('l')
ligado = 1
else:
ser.write('d')
ligado = 0
if __name__ == '__main__':
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment