Tutorials/Basic logic gates

From Minecraft Wiki
Jump to: navigation, search
This page or section has been suggested to be merged with Logic circuit. Discuss
The articles share similar information or a common topic.
Mcredstonesim icon.png
This article makes use of diagrams in the MCRedstoneSim format for compactness and clarity.
Some of the designs are more than two blocks high which is represented here by the layers being frames in an animated gif or labeled side by side. A full legend is on the Redstone schematics page.

Logic gates in Minecraft are a way of using redstone circuits in a manner that a certain combination of inputs, or redstone signals, achieves a certain output. They are similar to computer logic gates in a way, but are slightly different in their constructs.

Basic Info[edit]

Some basic info about Minecraft needed to understand redstone circuits and gates:

Key for Diagrams[edit]

MCGatesKey.png

Using Logic Gates[edit]

The most basic gate you can have. When the input signal is on, the output signal is on, and vice versa.
Input/Output Gate
The most basic gate you can have. When the input signal is on, the output signal is on, and vice versa.

Logic gates are used to create circuits more complex than a single on/off switch. For instance, if you wanted to have a redstone lamp light only when two switches were both toggled to the "on" position, you would use an AND gate. If you wanted no signal when a switch is on, but wanted a signal when a switch is off, you would use a NOT gate. Lighting in modern buildings controlled by two or more switches (for example: a light in a hallway with a switch at each end) use XOR gates.

Gates can be used in combinations to create complex signal patterns, and some have even successfully created redstone computers using logic gates. See Tutorials/Advanced redstone circuits for more info.

Examples of Logic Gates[edit]

NOT Gate[edit]

The most commonly used NOT gate. Also called an inverter.
Interactive Schematic
NOT Gate (On)
The most commonly used NOT gate. Also called an inverter.
NOT Gate (Off)
The most commonly used NOT gate. Also called an inverter.

A NOT gate (¬A), also known as an inverter, is a gate used when an opposite output is wanted from the input given. For instance, when the switch, or input, is set to "on", the output will be toggled to "off", and when the switch is toggled to "off", the output will be toggled to "on".

Input Output
ON off
off ON

AND Gate[edit]

A commonly used AND gate.
Interactive Schematic
AND Gate
A commonly used AND gate.

An AND gate (A ∧ B) is used with two or more switches or other inputs. The output is toggled to "on" ONLY when both switches, or inputs, are toggled to "on". Otherwise, the output will remain "off". In reality, the image provided is a NOR gate with inverted inputs. By taking the logic of A and B, the first two torches (top and bottom from the image) invert them into ¬A ∨ ¬B, then the third torch (the center-right one) applies a NOT to that statement. Thus it becomes ¬(¬A ∨ ¬B), which can be interpreted as A ∧ B by De Morgan's Law.

Input 1 Input 2 Output
ON ON ON
ON off off
off ON off
off off off

NAND Gate[edit]

A commonly used NAND gate. Note the similarities to the AND gate.
Interactive Schematic
NAND Gate
A commonly used NAND gate. Note the similarities to the AND gate.

A NAND gate (¬(A ∧ B)) is the opposite to the AND gate. The output is toggled to "off" ONLY when both switches are toggled to "on". Otherwise, the output is set to "on". This gate also requires two or more inputs. (By De Morgan's Law, (¬(A ∨ B)) is identical to (¬A ∧ ¬B)

Input 1 Input 2 Output
ON ON off
ON off ON
off ON ON
off off ON

OR Gate[edit]

Two isolated OR gates. These can have up to 3 normal inputs, or more if inverted inputs are used with redstone torches above and/or below the yellow block or output dust.
An implicit OR gate. This is the simplest gate available and therefore easily forgotten. This gate is potentially dangerous as signals may flow back to any circuitry attached to the inputs. This has been solved with diodes in the circuit on the right. The number of inputs is only limited by the available signal strengths. Using the transparent block trick, even more inputs can be added.

An OR gate (A ∨ B) uses two or more inputs. Whenever any input is "on", the output is to "on". The only time the output is "off" is when all inputs are "off".

Input 1 Input 2 Output
ON ON ON
ON off ON
off ON ON
off off off

NOR Gate[edit]

A NOR gate. Note the similarities to the OR gate.
Interactive Schematic
NOR Gate
A commonly used NOR gate. Note the similarities to the OR gate.

A NOR gate (¬(A ∨ B)) is the opposite of the OR gate. Whenever at least one switch is toggled to "on", the output is toggled to "off". The only time the output is "on" is when all inputs are toggled to "off". This gate also uses two or more inputs.

Input 1 Input 2 Output
ON ON off
ON off off
off ON off
off off ON

XOR Gate[edit]

A commonly-used XOR gate.
Interactive Schematic
XOR Gate
A commonly used XOR gate.

An XOR gate (A ⊻ B) is a gate that uses two inputs. In this gate, the output is toggled to "on" when one switch is "on" and one switch is "off". If both switches are in the same position, the output is toggled to "off". Because of these properties, XOR gates are commonly found in complex redstone circuits. In some cases, it is possible to get an OR gate output and an AND gate output on different channels. (The reason why it is possible is because, the circuit above is composed out of AND gates, OR gates and NOT gates. The whole circuit is ¬(¬(A ∨ B) ∨ A) ∨ ¬(¬(A ∨ B) ∨ B), which can be further simplified into (¬A ∧ B) ∨ (A ∧ ¬B) )

Input 1 Input 2 Output
ON ON off
ON off ON
off ON ON
off off off
XOR Gate
Another, simpler XOR gate.

XNOR Gate[edit]

A commonly-used XNOR gate. Note the similarities to the XOR gate.
Interactive Schematic

An XNOR gate (A ↔ B) is the opposite of an XOR gate. It uses two inputs. When both switches are in the same state (both switches are "on" or both switches are "off"), then the output is toggled to "on". Otherwise, if the switches differ, the output is toggled to "off".

Input 1 Input 2 Output
ON ON ON
ON off off
off ON off
off off ON

NOTE: The capital N in every gate listed above means NOT. For example, the NAND gate means NOT AND, thus anytime an AND gate would output an "on" signal, a NAND gate would output "off." And anytime an AND gate would output "off," a NAND gate would output an "on" signal. Important Note for beginners to the concept of logic gates: Some explanations use terms like "low-power" and "high-power" to describe signal inputs and outputs of logic gates. "Low-power" is akin to "off," and "high-power" is akin to an "on" signal.

ONLY / NON-IMPLY Gate[edit]

NOTE: This 'gate' is just a special case of a NOR gate where one of the inputs is inverted.

In this gate, the output is toggled to "on" only when input A is "on" and input B is "off". If input A is "off" and input B is "on", the output will remain "off". If both inputs are "off" or "on", the output will remain "off". This makes this gate useful when needing a specific order of inputs to trigger the output.

An ONLY gate.
Interactive Schematic
An ONLY gate using a comparator in subtraction mode. This can only be used as a gate when the signal strength in Input B is greater than or equal to that of Input A. In the Bedrock Edition, the redstone wire on the side of the comparator is replaced by a repeater facing the comparator.
Input 1 Input 2 Output
ON ON off
ON off ON
off ON off
off off off

Diodes[edit]

Diodes prevent power from flowing backwards in a circuit. This can be very useful if the player needs to isolate an input wire to avoid feedback, or need to merge two inputs into one (such as in the OR gate above).
There are three flavors of diodes: The one-block one (up to four) tick delay repeater, the three-block two tick delay redstone torch repeater that is also called a classic or traditional repeater, and the two-block, zero tick delay glowstone diode.

Two repeaters used in a compact wire crossing.
Interactive Schematic

Repeater[edit]

Repeater based diodes are the easiest to make, by simply placing a repeater in a line of redstone, the player have a simple one-tick delay diode. This simple mechanism can be seen demonstrated in the image to the right.

Torch Repeater[edit]

A basic traditional repeater design.
Interactive Schematic

Torch based repeaters are effective for making diodes (at a heavy cost of two ticks, however) because torches do not go out if you power them from a block they are not attached to. They are simply two NOT gates (and can be spaced much wider, allowing more transmission range at a lower cost than repeaters), by placing two solid blocks (not glass, glowstone, leaves, etc.) then a torch on the top of the block you're sending power to you create the first NOT gate, you then lay wire on the second block and place a torch on one side, this second torch will be switched off after a brief pulse, by the torch on the first block. If the player like, they can also lay wire instead of placing the torch immediately, up to 15 blocks of it; after 15 blocks, however, you must place a third block at the very end and place the second torch on one side of that before you continue laying wire.

A possible alternative to placing two blocks for the first torch if you're doing long distance transmission is to dig one block down, and place wire in the hole then place a torch on the block the wire in the hole connects to. This will give you the final block for the other NOT gate as well, so you don't need to carry spare blocks for the repeaters or diodes.

Glowstone, Stairs, and Slabs[edit]

Glowstone, stairs, and slabs are utilities in redstone circuits due to a few interesting features of how they transmit power. They all:

  • Allow power to go through their lower and upper edges (see vertical transmission below)
  • Allow power to transmit up to a wire on its surface (top).
  • Do not allow power to transmit from its surface to a block below.

That last feature is the most used. Among other things, it allows the use of these to construct a diode. Placing redstone up to one of these blocks, across to a normal block on the same level, then back down (see figure), creates a zero-tick-delay diode that prevents feedback loops in time-sensitive circuits.

That same feature also allows for 1-wide, 2-deep instant vertical redstone transmission.

Video[edit]

See also[edit]