Programming instructions

Reference
Project Lead The Way
©
and Carnegie Mellon Robotics Academy
©
/ For use with VEX
®
Robotics Systems
Pseudo Code & Flow Charts 2
Pseudocode & Flow Charts
Flow Charts are a visual representation of program ow. A ow chart normally uses a
combination of blocks and arrows to represent actions and sequence. Blocks typically
represent actions. The order in which actions occur is shown using arrows that point from
statement to statement. Sometimes a block will have multiple arrows coming out of it,
representing a step where a decision must be made about which path to follow.
Decision
Action
Start and End symbols are represented as rounded rectangles,
usually containing the word “Start” or “End”, but can be more
specic such as “Power Robot Off” or “Stop All Motors”.
Actions are represented as rectangles and act as basic
commands. Examples: “wait 1 second”; “increment LineCount
by 1”; or “motors full ahead”.
Decision blocks are represented as diamonds. These typically
contain Yes/No questions. Decision blocks have two or
more arrows coming out of them, representing the different
paths that can be followed, depending on the outcome of the
decision. The arrows should always be labeled accordingly.
To the right is the ow chart of a program
which instructs a robot to run the right motor
forward as long as its touch sensor is not
pressed. When the touch sensor is pressed
the motor stops and the program ends.
To read the ow chart:
Start at the “Start” block, and follow its
arrow down to the “Decision” block.
The decision block checks the status of
the touch sensor against two possible
outcomes: the touch sensor is either
pressed or not pressed.
If the touch sensor is not pressed, the
program follows the “No” arrow to the
action block on the right, which tells the
right motor to run forward. The arrow
leading out of that block points back
up and around, and ends back at the
Decision block. This forms a loop!
The loop may end up repeating many
times, as long as the Touch Sensor
remains unpressed.
If the touch sensor is pressed, the
program follows the “Yes” arrow and
stops the motors, then ends the program.
Start
Is the Touch
Sensor
pressed?
End
Run the Right
Motor
Stop
Motor
No
Start/Stop
Go to Reference Links