Ejemplo n.º 1
0
m = Mirobot()					# Create the object to use

# Movement

m.forward(100)			# Move forward by 100 mm

m.back(100)

m.left(45)				# Turn left by 45 degrees

m.right(90)

# Pen Control

m.penup()					# Move the pen up

m.pendown()

# Sensors

colliding = m.collideState()		# may be left, right, both or none

# Other functions

m.beep(500)				# Beep for 500 mS (1/2 a second)

m.ping()					# Pings the mirobot for a response

Language
Ejemplo n.º 2
0
mirobot = Mirobot(debug=True)
# Autoconnect to a Mirobot on our network (there can be only one)
mirobot.autoConnect()

# Get a menu so we can select which Mirobot to connect to
#mirobot.autoConnect(interactive=True)

# Specify the id of the Mirobot we want to connect to
#mirobot.autoConnect(id='Mirobot-abcd')

print("Mirobot version: %s" % mirobot.version)

# set up error handling
mirobot.errorNotify(on_error)

mirobot.forward(100)
mirobot.right(90)
mirobot.back(100)
mirobot.penup()

while True:
  state = mirobot.collideState()
  if state == 'left':
    mirobot.back(100)
    mirobot.left(90)
  if state == 'right':
    mirobot.back(100)
    mirobot.right(90)
  else:
    mirobot.forward(10)