- :-

Topics Covered

  • Custom Logic Loop
  • Logic Operations Block
  • Lesson Links

    Check Your Understanding:
    1. 1. What values can a Logic value have?
    2. Number from 0 and 100
      Letters and words
      Yes/True and No/False
      Number of times program looped
    3. 2. A Logic Loop will repeat when the Logic value wired into it is...
    4. Yes/True
      No/False
      Wired
      Missing
    5. 3. The Logic Loop allows you to...
    6. Make a loop that exits based on a custom condition you specify with logic
      Combine multiple numeric values into one
      Control more motors
      Active sensors more frequently
    Try It!
    Try it! 1

    "OR" vs "AND"

    Change the Logic Operations Block's Mode from "OR" to "AND".
    Run the program, and see if you can get your robot to stop!
    What happens?
    The robot wil only stop when the Touch Sensor is pressed AND the Rotation Sensor has passed 5 rotations!
    Mini Challenge

    Mini Challenge 1: Forward until Touch OR Rotations OR Near

    In this lesson, you created a custom logic loop that exits if one of two conditions is met.
    But can you have more than two conditions to choose from?

    Upgrade your custom logic loop you created in this lesson to exit
    if one of the following 3 conditions is met.

    • Robot's touch sensor has been pressed
    • Robot has traveled 5 rotations forward
    • Robot is within 20cm of an object or a wall

    Just like Rotation Sensor Block set to "compare" number of rotations, Ultrasonic Sensor Block can be set to "compare" number of centimeters.

    Your first Logic Operations Block determines whether one of "a" or "b" is "Yes"/True". If it is, it will output "Yes/True" from its Output plug. To test for a third condition, where should this output plug should be connected to?

    Logic Operations Blocks cannot accept more than 2 logic inputs. However, you can use more than one Logic Operations Block.

    Add a second Logic Operations Block that will accept logic output from the first Logic Operations Block as its 'a', and will accept logic value from Ultrasonic Sensor Block as its 'b'.

    + hint

    Mini Challenge 2: Line Track until Touch or Near

    You robot can do more than simply moving forward while watching out for multiple stop conditions.

    Create a line tracking robot that will stop if one of the following two conditions are met:

    • Robot's touch sensor has been pressed
    • Robot is within 20cm of an object or a wall

    Keep in mind that line tracking behavior is performed using a loop. Change this loop's mode into "Logic" to create a custom logic loop.

    After the robot decides which motor should be used (switch), add Sensor Blocks and Logic Operations Block to complete your custom logic loop

    + hint