Guest User

Control scroll bar in python with arduino

a guest
May 6th, 2014
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. import time, sys, serial
  2. toolbar_width = 70
  3. ser = serial.Serial('COM3', 9600)
  4. # setup toolbar
  5. sys.stdout.write("[%s]" % (" " * toolbar_width))
  6. sys.stdout.flush()
  7. sys.stdout.write("\b" * (toolbar_width+1)) # return to start of line, after '['
  8. for i in xrange(toolbar_width):
  9.     info = ser.readline()
  10.     time.sleep(int(info)/1000)
  11.     # update the bar
  12.     sys.stdout.write("*")
  13.     sys.stdout.flush()
  14. sys.stdout.write("]\nFinished!")
Advertisement
Add Comment
Please, Sign In to add comment