Coding with PROTO

This page is printable! Set margins to none in the print menu to remove the page name and other information from the PDF.

General

Always start every program with import make

Name your componants before you use them to take actions.

Everything after a # is ignored by the program — use that to explain what the code does in English while you write it!

Time

make.wait()
make.wait(seconds)

make.wait_until(action)
make.wait_while(action)

Naming Motors

motor = make.largemotor(port)
motor = make.largemotor(port, direction)

motor = make.smallmotor(port)
motor = make.smallmotor(port, direction)

Moving Motors

motor.spin(power)
motor.spin(power, time)

motor.spin_back(power)
motor.spin_back(power, time)

motor.stop()

Naming Servos

servo = make.servo(port)

Moving Servos

servo.moveto(angle)

Naming Buttons

button = make.button(port)

Reading Buttons

button.pressed()
button.held()

Naming Drivetrains

dt = make.drivetrain(left, right)
dt = make.drivetrain(left, right, drift)
                    

Moving Drivetrains

dt.drive(power)
dt.drive(power, time)
dt.drive_back(power, time)

dt.turn(power)
dt.turn(power, time)
dt.turn_back(power, time)

dt.curve(left, right)
dt.curve(left, right, time)
dt.curve_back(left, right, time)

dt.stop()

Examples

Drive Forward

import make

# name your motors!
left = make.largemotor(6)
right = make.largemotor(7)

# spin both motors forwards
left.spin(100)
right.spin(100)
# wait for 2 seconds
make.wait(2)
# stop both motors
left.stop()
right.stop()

Spin Until Stopped

import make

# name your motors!
left = make.largemotor(6)
right = make.largemotor(7)

# name your button
stop_button = make.button(8)

# spin one motor forwards, and other back
left.spin(100)
right.spin_back(100)
# wait until the stop button is pressed
make.wait_until(stop_button.pressed)
# stop both motors
left.stop()
right.stop()