Let’s explore some of our smartest modules: the logic modules! The double AND, double OR, NAND, NOR, and XOR all have specific characteristics that require two inputs to be in a certain state (ON/OFF) before the output can be activated. Building circuits with logic modules is practically the equivalent of physical programming, at a littleBits level. Let’s break it down.
When using logic modules, you need two input modules. Therefore, you will need to provide power to both of the input modules. This can be done two ways. You can either power the input modules by branching the power with a split, a branch, or a fork or you can use two separate power modules to power each input individually. You can also use branches, forks, and splits after the output of the logic modules to send the signal to multiple places.
Logic modules only work with two states of inputs, ON and OFF. When an input is either ON or OFF, like a button, a toggle switch, or a sound trigger, we call it a digital input. Inputs that have variable voltage like pressure sensors, dimmers, and light sensors, are analog inputs. Because logic gates only deal with ON/OFF, high/low, or true/false, analog signals pass as digital. With analog inputs, an “ON” signal occurs at about 2.5 volts when passing through a logic gate.
Also in logic circuits, you may want to hold the state of a momentary input (like a button). In order to hold this state, you can use a latch. You can also use a timeout to hold the state for a certain period of time. To see an example of this, check out the circuit for the Programmable Safe.
Now, let’s dive into each logic gate to understand how they work:
The double AND module is a logic gate with two inputs and one output. In order for the AND gate to output an on signal, both inputs need to be on at the same time. When this happens, you are able to activate any output module like an LED, a DC motor, or a buzzer. The double AND module is a good option for projects in which you want two actions to trigger another.
The double OR module is a logic gate with two inputs and one output. In order for the double OR gate to output an on signal, the first input, the second input, or both inputs need to be on. When both inputs are off (inactive), the output is off. The double OR is good option for projects where you want to detect two inputs but don’t care which input is activated.
The XOR module is a logic gate with two inputs and one output. In order for the XOR gate to output an on signal, either one of its inputs, but not both, are on. The XOR is called the exclusive OR because it is similar to the OR gate, but only outputs a signal when one input is on at a time. The XOR is great for projects in which the activation requires input alternation.
The NAND module is a logic gate with two inputs and one output. NAND is short for NOT AND which is the combination of an AND gate where the output is inverted. The NAND only outputs an off signal when both of the inputs are on, or true. If both inputs are off, the output signal will be on.
The NOR module is a logic gate with two inputs and one output. NOR stands for NOT OR, meaning the output of the OR module is inverted. With the NOR module, the output is on when both inputs are off, or false. If either or both inputs are on, the output will be off, or false. The NOR gate is good for projects in which you want the output to be on unless one or both of its inputs are triggered.
Inverters can be used in combination with logic gates to change how the logic works. If you place the inverter after the output of a gate, it will change the logic completely. If you place the inverter before one input, it changes the logic going into the gate from that input. You can also use inverters to negate logic blocks and build them out of each other, i.e. AND + inverter = NAND, OR +inverter= NOR.
These projects all use logic to achieve interesting interactions:
1. Morning Sunshine (double AND)
This alarm clock utilizes the double AND Bit and allows you to create an alarm that goes off with the sun, but only works when you are around.
2. littleSpace Command Capsule (AND)
This interactive command capsule helps aspiring astronauts prepare for blast off! Using the double AND Bit, both inputs must be activated in order for the shuttle to take off.
3. Ring Modulation (XOR)
Have a Synth kit? Try boosting it with an XOR to create a simple ring modulator, an addition that will allow you to create complex sounds that in our opinion, sound eerie, wobbly, metallic, droney and totally amazing.
4. Magic 8 Machine (NOR & double OR)
The Magic 8 Machine has an interior mechanism that is both activated and stopped through a set of logic modules, the NOR and the double OR. Either speak into the box to ask your question OR press your forehead against it to have it read your mind. There are four possible answers you can receive depending on when the inputs are activated by the interior servo mechanism.
5. Lockout Buzzer (NAND)
This logic circuit is commonly used in a gameshow scenario where each contestant has a buzzer to press to give the answer to a question. Think Jeopardy or Double Dare. The person who presses their buzzer first gets the first chance to give an answer. The awesome thing about this circuit is that the NAND gates make it impossible to cheat. When one person buzzes in, the other contestant’s buzzers are disabled. This is especially useful in situations where two people might buzz in at what seems like the same time, but one person is actually nanoseconds ahead!