Академический Документы
Профессиональный Документы
Культура Документы
Flowcharts
Flowcharts
A owchart visually represents and organizes the steps used to write the programit is a diagram of the ow of the
process. When programmers write code, they need to give the robot instructions that are both sequential and specic.
Flowcharts enable programmers to work these steps out before needing to translate their behaviors into code.
Reading owcharts
Move from step to step in the chart by following the lines between them. Perform any action listed when you
reach a Statement Block (rectangle), and then choose from several different paths to follow when you reach a
Decision Block (diamond).
Start
or a behavior to perform.
No
Yes
End
Exercises
1. In the owchart above, what will be the rst action you take? _________________________________________________________
2. If you havent gone 50 steps yet, what will you do next? ____________________________________________________________
3. If youve gone 50 steps, what do you do? ______________________________________________________________________
4. Describe the eventual result of your actions if you follow the owchart above from start to nish. ________________________________
_____________________________________________________________________________________________________
NAME
DATE
6.5
Programming
Flowcharts
Writing Flowcharts
How do you get from a complex task to an organized owchart describing how to do it? Start with a owchart
containing just the task. Now break it down into smaller, more specic steps in another owchart. Then, go back
and see if you can break down any of those behaviors into simpler parts. Keep on repeating this process until youve
reached steps that are simple enough for your robot to perform!
Start
Start
Wash hands
Start
Turn on water
Wash hands
Turn on water
Dispense soap
Dispense soap
Wash hands
Wash hands
till clean
Hands
clean?
Yes
Dry hands
Dry hands
End
End
End
Exercise
5. On a separate sheet of paper, make a owchart organizing the ow of getting ready to go to school in the morning.
Be sure to include the following steps in your chart, but dont be afraid to add other things if you need them!
NAME
DATE
6.6
Programming
Flowcharts
Exercises
Pump air
Tire at rated
pressure?
No
Yes
End
NAME
DATE
6.7
Programming Teacher
Flowcharts
Exercises
1. In the owchart above, what will be the rst action you take?
Take one step forward.
4. Describe the eventual result of your actions if you follow the owchart above from start to nish.
You will walk forward for 50 steps.
6.8
Teacher Programming
Flowcharts
5. (This is a sample answer only. Student answers may vary.)
Start
Select something
to wear
Check your
alarm clock
Hit snooze button
Time
to get up?
Get dressed
No
Yes
Found
shoes?
Put toast
in the toaster
No
Yes
Put shoes on
Eat breakfast
Wait
Brush teeth
Check
time to
leave
Turn on shower
Water at
correct
temperature
No
Yes
Adjust water
temperature
Leave house
No
Yes
End
Take shower
Comb hair
6.9
Programming Teacher
Flowcharts
Exercises
7.
Start
Start
Take 20 paces
Raining
Outside?
Take a step
Yes
Bring umbrella
No
Gone 20
paces?
End
Yes
c. Go forward until the Touch Sensor (on port 1)
Turn around
Start
Shoot
Go forward
Touch
sensor
pressed?
Yes
Stop robot
End
End
No
Note: Stopping the robot is not the same as the program stopping
because its reached its end. Stopping the robot means bringing it to
a physical halt, whereas ending the program simply means no more
commands are issued.
This is an important distinction to make for later on.
6.10
No
Teacher Programming
Flowcharts
7. d. Follow Liberty Avenue for 2 miles, then take a left turn onto 40th Street. Go until you reach the bridge,
but dont cross the bridge. Instead, make a right turn onto Foster Street, then take the rst left turn.
Follow that road until you reach the National Robotics Engineering Consortium building.
Start
Follow Foster St.
Gone
2 miles?
Reached
left turn?
No
No
Yes
Yes
Turn left
Reached
bridge?
Reached
NREC?
No
No
Yes
Yes
End
6.11
Programming Teacher
Flowcharts
7. e. Turn on oven. Cook turkey for 4 hours or until meat thermometer reaches 180 degrees.
Note: This key word in this exercise is the word
OR between the two conditions. As an additional
exercise, consider the ways in which this diagram
would change if you replaced the word OR with the
word AND.
Start
Turn on oven
Wait
Yes
4 hours
elapsed?
No
Therm.
at 180?
No
Yes
End
8. Make a ow chart for the process of crossing the street.
Hint: Looking both ways wont do any good unless you use that information to make some decisions.
Start
Look left
See cars
coming?
Yes
No
Look right
See cars
coming?
Yes
No
Cross street
2005 Robomatter Inc. RE 2.5_RW 1.1
6.12
End
Teacher Programming
Flowcharts
9. Bonus: Write a ow chart that tells you how to read ow charts.
Start
Go the start block
in the owchart
Follow the line to
the next block
Reached
a statement
block?
Follow the NO line
to the next block
Yes
Answer
to question
is No?
Yes
No
Yes
No
Answer
to question
is Yes?
Yes
Reached
a decision
block?
No
No
ERROR in owchart
No
Reached
an end
block?
Yes
End
6.13