Tutorials/Basic logic gates

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
Some basic info about Minecraft needed to understand redstone circuits and gates:
 * There are several items that can provide an input charge into redstone. These are levers, pressure plates, redstone torches, buttons, detector rails, and tripwire hooks.
 * Switches are most commonly used with gates because of their ease of use and the fact that they are easily made.
 * When redstone torches are powered, they go into an "off" state and stop providing power themselves.
 * Any block can have redstone placed on it except leaves and glass, with a few more exceptions.
 * Glowstone can have redstone wire placed on it, but not torches or repeaters.

Using Logic Gates
One uses gates when they need a different signal pattern than a simple on/off pattern, but a gate can be as simple as that: an On-On, Off-Off gate. However, other gates are used when one wants to have a signal go on when a certain combination of events happens. 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 a gate. If you wanted no signal when a switch is on, but wanted a signal when a switch is off, you would use a gate. Gates can be used in combinations to create complex signal patterns, and some have even became successful in creating redstone computers using logic gates. See Tutorials/Advanced Redstone Circuits for more info.

NOT Gate
A NOT gate, sometimes called an inverter, is a gate used when you want an opposite output from the input you give. 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".

AND Gate
An AND gate 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".

NAND Gate
A NAND gate 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.

OR Gate
An OR gate uses two or more inputs. Whenever a switch is toggled to "on", the output is toggled to "on". The only time the output is "off" is when all switches are switched to "off".

NOR Gate
A NOR gate 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.

XOR Gate
An XOR gate 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 are "on" or "off", then the output is toggled to "off".

XNOR Gate
An XNOR gate is the opposite of an XOR gate. It uses two inputs. When both switches are "on" or both switches are "off", then the output is toggled to "on". Otherwise, the output is toggled to "off".

Diodes
Diodes prevent power from flowing backwards in a circuit. This can be very useful if you need 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 (also called a classic or traditional repeater), and the two-block, zero tick delay Glowstone diode.



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

Torch Repeater
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 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, careful!) by the torch on the first block. If you like, you 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 your repeaters/diodes.



Glowstone
Glowstone's utility in redstone circuits is due to a few interesting features of how it transmits power. Glowstone:


 * allows power to transmit from a wire at its level to a wire directly below it in a hole and visa versa.
 * allows power to transmit up to a wire on its surface (top).
 * does not allow power to transmit from its surface to a block below.

That last feature allow the use of glowstone to construct a diode. Placing redstone up to a glowstone block, 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.

In version 1.3 upside down slabs transmit power in the same way as glowstone, allowing you to make these diodes out of stone or wood slabs, making them much easier to obtain and completely renewable.