Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time, sys, serial
- toolbar_width = 70
- ser = serial.Serial('COM3', 9600)
- # setup toolbar
- sys.stdout.write("[%s]" % (" " * toolbar_width))
- sys.stdout.flush()
- sys.stdout.write("\b" * (toolbar_width+1)) # return to start of line, after '['
- for i in xrange(toolbar_width):
- info = ser.readline()
- time.sleep(int(info)/1000)
- # update the bar
- sys.stdout.write("*")
- sys.stdout.flush()
- sys.stdout.write("]\nFinished!")
Advertisement
Add Comment
Please, Sign In to add comment