The control program

The second part of the program, the control loop BHV, has its own Start block, which allows this part of the program to run in parallel to the main programming loop. At the beginning, the st Variable block sets the robot state to 0 or resting. The program then enters the BHV Loop block or the robot behavior loop.

A numeric switch block examines which of the three robot states the robot is in, with 0 for resting state, 1 for waking state, and 2 for the active state. The resting state (state 0) is the default case of the switch block. In this state, the variables blocks Cdrv and Cstr are set to 0. The Cdrv variables block (Control drive) is used to control the speed at which the robot drives either forward or backwards. The ...

Get Learning LEGO MINDSTORMS EV3 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.