Book Image

Learning Lego Mindstorms EV3

By : Gary Garber
Book Image

Learning Lego Mindstorms EV3

By: Gary Garber

Overview of this book

Table of Contents (19 chapters)
Learning LEGO MINDSTORMS EV3
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
10
Other Programming Languages
Index

Three-level controller


Now, let's examine a version of this program using the rotation sensor. This program is similar to the previous program except that the angle is set to 400 (the probable rotation of the wheels) and the blocks are set to the rotation sensors instead of the Gyro Sensors. The Gyro program used a two-level controller. A path in the case structure was chosen based on the robot's position relative to a setpoint value. Notice that, in this program, I have a switch within a switch. This allows for a three-level controller. When the robot is actually at the set-point value, no motion takes place.

In the preceding screenshot, you can see the path the switch takes for the true case of when the Motor Rotation sensor is greater than the value of the angle variable. In the following screenshot, you can see the false case, when the value is not greater than the value of the angle variable. You can see in the screenshot that to make three levels we need the switch within a switch....