Skip to content

Instantly share code, notes, and snippets.

@fbrosser
Created March 30, 2012 13:27
Show Gist options
  • Save fbrosser/2251557 to your computer and use it in GitHub Desktop.
Save fbrosser/2251557 to your computer and use it in GitHub Desktop.
Python serial
import serial
import sys
ser = serial.Serial('/dev/ttyUSB0', 9600)
ys = "";
xs = "";
i = 0
while 1:
xs = "";
x = 'q';
while(x != '\n'):
x = ser.read()
xs += x;
if(ys != xs):
sys.stdout.write("(" + str(i) + ")\t\t" + xs)
i = i+1
ys = xs;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment