PICOBOTZ
PICOBOTZ
© iBOTZ (Ireland) Limited.2004.
No part of this manual may be reproduced with express permission of iBOTZ (Ireland) Limited
.
12
Activity 8: While Loops
In this Activity, you will learn about While loops.
Click the Measure button
to display the Measure dialog:
Watch the Light Chart and point the robot at a bright light source. You should see the light level
rise.
You can test whether the Light level is greater that it was before (that is, greater than it was last
time you asked). For instance:
If Light > Prev then
<instructions>
End
(You learned about If instructions in Activity 5.)
The robot tests whether the current light level is greater than "Prev" - its previous level. It then
sets "Prev" to the current light level.
Use the While and Motors Programming pages to write this program:
Set the Motor Mode to On-del-off.
Download and run the program. The robot should spin until it sees a brighter light such as a
window or desk-lamp then head off in a straight line.
The While loop is executed as long as the condition "NOT Light > Prev" is true. If "NOT Light >
Prev" is never true then the loop is never executed.
Activity 9: Repeat Loops