16. Logic Operations & Decision Making

You must first complete 15. Parallel Beams before viewing this Lesson

– The Logic Bock does a Logic operation on its inputs, and outputs the result
– A Logic Block takes inputs that are True or False, and produces a True or False output
– Logic values can be used as inputs into loop exists and
switch conditions.
– It is found in the Red Programming Pallet tab

16.1. Different Modes in the Logic Block

Logic Blocks in Three Easy Steps

Challenge 1:

Make your robot drive forward until EITHER the Touch Sensor is pressed or the Color Sensor detects black.

STEP 1: Turn the motors on

STEP 2: Add the Logic and Sensor Blocks

A. Use a Logic Block in the OR mode
B. Add the inputs: Take a color sensor and a touch sensor blocks and wire them into the Logic Block as inputs

STEP 3: Add a Loop and loop exit condition:

Place the Sensor and Logic Blocks in a loop

Hint For the exit condition of the loop, select logic. Wire the result of the Logic Block into the exit condition. If the result of STEP 2 is True, you should exit the loop and stop the robot.

Back to: Module 3. Programming