Programming the false case
We can now write some programming inside of the switch. We will start with the false case because it is simpler. This case will run if IR 2 does not see a beacon. If there is no nearby beacon, we simply want the robot to stop and wait until one is present.
Add three motor blocks into the bottom case of the switch. Each of these will stop the corresponding motor. The first block is a medium motor block. Set its mode to Off and set its port to A. This will halt the medium motor in port A, which controls the firing of the turret.
The second motor block will be a move tank block, which simultaneously controls the two drive motors. Set the mode of this block to Off as well. This will stop the robot's driving if no beacon ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access