Programming instructions
Reference
Project Lead The Way
©
and Carnegie Mellon Robotics Academy
©
/ For use with VEX
®
Robotics Systems
Behaviors • 2
Behaviors
Sometimes it can be hard to tell whether a behavior is “simple” or “complex”. Some programs
are so complex they need multiple layers of simple behaviors before they reach the basic
ones!
“Basic,” “Simple,” and “Complex” are categories of behaviors which are meant to help you
think about the structure of programs. They are points of reference in the world of behaviors.
Use these distinctions to help you, but don’t worry if your “complex” behavior suddenly
becomes a “simple” part of your next program... just pick the point of reference
Composition and Analysis
Perhaps the most important idea in behaviors is that they can be built up or broken down
into other behaviors. Complex behaviors, like going through a maze, can always be broken
down into smaller, simpler behaviors. These in turn can be broken down further and further
until you reach simple or basic behaviors that you recognize and can program.
By looking back at the path of behaviors you broke down, you can also see how the smaller
behaviors should be programmed so that they combine back together, and produce the
larger behavior. In this way, analyzing a complex behavior maps out the pieces that need to
be programmed, then allows you to program them, and put them together to build the nal
product.
Go forward for
3 seconds
Turn on left motor
Turn on right motor
Wait 3 seconds
Turn off left motor
Turn off right motor
Follow the path to
reach the goal
Go forward 3 seconds
Turn left 90º
Go forward 5 seconds
Turn right 90º
Go forward 2 seconds
Turn right 90º
Go forward 2 seconds
Turn left 90º
Reverse left motor
Turn on right motor
Wait 0.8 seconds
Turn off left motor
Turn off right motor
Go forward for
5 seconds
Turn on left motor
Turn on right motor
Wait 5 seconds
1. Turn on left motor
2. Turn on right motor
3. Wait 3 seconds
4. Turn off left motor
5. Turn off right motor
6. Reverse left motor
7. Turn on right motor
8. Wait 0.8 seconds
9. Turn off left motor
10. Turn off right motor
11. Turn on left motor
12. Turn on right motor
13. Wait 5 seconds
...
Large behavior Smaller behaviors ROBOTC-ready behaviors
Step by step
1. Start with a large-
scale behavior that
solves the problem.
2. Break it down into
smaller pieces. Then
break the smaller
pieces down as well.
3. Repeat until you
have behaviors that
are small enough
for ROBOTC to
understand.
Go to Reference Links