Pasted below are 2 modules that I have written for the scribblers. When I start the python shell, I type the command
>>> from start import *
which imports all the myro commands, connects the scribbler to your computer, and finally imports some shapes he can draw.
***NOTE*** In the start file on the second line, you may change this if your COM port connection is variable each time the robot connects. Mine is not and consistently connects to COM6.
START.PY FILE
from myro import * initialize("COM6") def turn(direction,angle): if direction == "left": turnLeft(1,(2.8/360*angle)) if direction == "right": turnRight(1,(2.8/360*angle)) stop() def walk(distance): forward(1,(0.09756*distance)) stop() from shapes import *
SHAPES.PY FILE
def square(size): walk(size) turn("right", 90) walk(size) turn("right", 90) walk(size) turn("right", 90) walk(size) turn("right", 90) stop() def pentagon(size): walk(size) turn("right", 324) walk(size) turn("right", 324) walk(size) turn("right", 324) walk(size) turn("right", 324) walk(size) turn("right", 324) stop() def spiral(): leftSpeed = 1 rightSpeed = 0 t = currentTime() while timeRemaining(10): for t in timer(10): rightSpeed = t/20 motors(leftSpeed, rightSpeed) stop()