SHARE
TWEET

Untitled

a guest May 10th, 2011 540 Never
  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"
RAW Paste Data
Top