uas_arduino

Python Serial Help

Apr 26th, 2013
36
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import serial
  2.  
  3. #Use for Linux
  4. ser = serial.Serial('/dev/ttyUSB0', 9600)
  5.  
  6. #Use for Windows
  7. ser = serial.Serial('YOU_COM', 9600)  # YOUR_COM needs to be the Windows COM port.
  8.  
  9. ser.write('asdf\n')  # write data to the serial port
  10. ser.inWaiting() # gets the number of bytes waiting to be read
  11. ser.read(X) # reads X number of bytes
RAW Paste Data