Programming instructions

Reference
Project Lead The Way
©
and Carnegie Mellon Robotics Academy
©
/ For use with VEX
®
Robotics Systems
Behaviors 1
Behaviors
Basic Behaviors
Example: Turn on Motor Port 3 at half power
At the most basic level, everything in a program
must be broken down into tiny behaviors that
your robot can understand and perform directly.
In ROBOTC, these are behaviors the size of
single statements, like turning on a single motor,
or resetting a timer.
Simple Behaviors
Example: Move forward for 2 seconds
Simple behaviors are small, bite-size behaviors
that allow your robot to perform a simple, yet
A behavior is anything your robot does: turning on a single motor is a behavior, moving
forward is a behavior, tracking a line is a behavior, navigating a maze is a behavior. There are
three main types of behaviors that we are concerned with: basic behaviors, simple behaviors,
and complex behaviors.
signicant task, like moving forward for a certain amount of time. These are perhaps the most
useful behaviors to think about, because they are big enough that you can describe useful
actions with them, but small enough that you can program them easily from basic ROBOTC
commands.
Complex Behaviors
Example: Follow a dened path through an entire maze
These are behaviors at the highest levels, such as navigating an entire maze. Though they
may seem complicated, one nice property of complex behaviors is that they are always
composed of smaller behaviors. If you observe a complex behavior, you can always break it
down into smaller and smaller behaviors until you eventually reach something you recognize.
task main()
{
bMotorReected[port2] = 1;
motor[port3] = 63;
motor[port2] = 63;
wait1Msec(2000);
motor[port3] = -63;
motor[port2] = 63;
wait1Msec(400);
motor[port3] = 63;
motor[port2] = 63;
wait1Msec(2000);
}
Complex
behavior
This code
makes the robot
move around a
Simple
behavior
This code
makes the
robot go
forward for
2 seconds at
half power.
Basic
behavior
This code
turns the left
motor on at
half power.
Go to Reference Links