Logic Block
The Logic Block is a tricky one to learn. It uses something called Logic Gates to give a boolean output based on inputs A and B which are also boolean. Before we can understand this block, we should learn logic gates.
Logic gates are used in computers. They allow you to compare two boolean variables and get an output based on which gates you used. To help understand this, lets look at our first gate: the AND Gate.
The AND Gate will give true output if both A and B are true. Otherwise, it would give false. So it does as its name says because it is only true if both inputs are true. Anything else will not work.
The next gate is called the OR gate. As you can imagine, this gate will give true if A or B are true. Otherwise it will give false.
Next is the NOT gate. This one is a bit nicer. It only has one input of A and it will always output whatever is not A. If A is true, output is false. If A is false, output is true.
Finally, the XOR gate. Now I don't know a word XOR however we do know the word OR. This gate comes from the OR gate. It will output true when A or B are true, just like the OR gate. However, there is a catch. The inputs A and B cannot both be true at the same time or it will output false. So it will only output true if A or B is true but not at the same time.
Going back to the logic block, you will notice under Operation there is a drop down menu with all the logic gates we discussed. Here you can select which logic gate to use based on what kind of an output you want. You will also notice there is a Vendiagram in the middle of this section that changes to help you understand the logic gate. You should also make sure that both A and B are on the Checkmark as shown below.
Logic gates are used in computers. They allow you to compare two boolean variables and get an output based on which gates you used. To help understand this, lets look at our first gate: the AND Gate.
The AND Gate will give true output if both A and B are true. Otherwise, it would give false. So it does as its name says because it is only true if both inputs are true. Anything else will not work.
The next gate is called the OR gate. As you can imagine, this gate will give true if A or B are true. Otherwise it will give false.
Next is the NOT gate. This one is a bit nicer. It only has one input of A and it will always output whatever is not A. If A is true, output is false. If A is false, output is true.
Finally, the XOR gate. Now I don't know a word XOR however we do know the word OR. This gate comes from the OR gate. It will output true when A or B are true, just like the OR gate. However, there is a catch. The inputs A and B cannot both be true at the same time or it will output false. So it will only output true if A or B is true but not at the same time.
Going back to the logic block, you will notice under Operation there is a drop down menu with all the logic gates we discussed. Here you can select which logic gate to use based on what kind of an output you want. You will also notice there is a Vendiagram in the middle of this section that changes to help you understand the logic gate. You should also make sure that both A and B are on the Checkmark as shown below.
To give you an idea of how to use this block lets say we were programming a two-player game. At the start of the game you check if both the players are ready to go. So each of them respond on the NXT and their responses get saved into two different variables. To check that they both said Yes, put both the variables through a logic block set on AND because we want to know if player 1 and player 2 are ready to play. If the output is true, start the game.
Back to Advanced Blocks