Advertisement
Guest User

Untitled

a guest
May 10th, 2011
694
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. import serial
  2. import time
  3.  
  4. baudrate = raw_input("Please enter the required baud rate:")
  5.  
  6. ## You need to add the locations for your system, i.e. COM* for Windows, /dev/tty* for Nix systems
  7.  
  8. locations=['COM3']
  9. for device in locations:
  10.     try:
  11.         print "Trying...", device
  12.         arduino = serial.Serial(device, baudrate)
  13.         break
  14.     except:
  15.         print "Failed.."
  16. count = 5
  17. time.sleep(1)
  18. while count < 10:
  19.     try:
  20.         print arduino.readline()
  21.     except:
  22.         print "Fail"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement