 |
 |
|
|
|
|
|
| Why would I need to use logic inputs and outputs in NXT-G? What is an example of a program that uses logic inputs and outputs? |
| (9 ) |
100%
0%
|
The logic block in NXT-G is essentially used to combine two or more true/false signals into one true/false value. For instance, you can have a motor change direction if both (A) the light sensor value is above 50 and/or (B) the sonic sensor value is below 30. There is also an 'Xor' funtion on the logic block that returns true if A or B are true, but false if A and B are true. You can also have the logic block return a true value if neither A or B are true, and return false otherwise. The true/false value can be wired to one of the pull-down tabs on any number of blocks in NXT-G that accepts true/false data types.
Below is an example of a program that checks to see if the combination of light and sound in the room is above 150 (ie. light value + sound value > 150) and whether or not a touch sensor is pressed. If both are true then the motor changes direction; otherwise, it continues in the forward direction.

This is the logic block's control menu for the program below. Notice that the \"And\" option is selected in the pulldown menu, designating that it will return true only if both inputs are true.

|