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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.