Advertisement
Guest User

robotito.py

a guest
Sep 3rd, 2012
631
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.49 KB | None | 0 0
  1. import time
  2. import random
  3.  
  4. from duinobot import *
  5. board = Board("/dev/ttyUSB0")
  6. board.report()
  7. robot = Robot(board, 5)
  8. try:
  9.     while True:
  10.         robot.forward(10)
  11.         print "Distancia:", robot.ping()
  12.         robot.beep()
  13.         if robot.getObstacle():
  14.             print "choque!"
  15.             angulo = random.randint(0,100)
  16.             print "girando", angulo, "grados!"
  17.             robot.turnLeft(angulo, 0.5)
  18.         time.sleep(1)
  19. finally:
  20.     robot.stop()
  21.     board.exit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement