Redstone Logic Gates: Mastering the Fundamental Building Blocks for Creating In-Game Machines
Many people get so discouraged by their failures with redstone that they give up using it entirely, or never progress beyond using simple switches. However, by incorporating logic gates into your redstone designs, the applications are nearly limitless. The ability to add multiple switches to your machines is just a small part of what logic gates can do. Most importantly, they give you control.
This handy graphic above is only really half the battle. Without knowing what all of these gates do, knowing how to make them is entirely useless. Unfortunately, if you don't already have a basic knowledge of digital logic, the Minecraft Wiki doesn't really do a very good job of explaining what they are and what they do. So, if you've been frustrated by logic gates before or are interested in learning them from scratch, hold on to your butts!
Starting from the very beginning, the term 'logic gate' just refers to an object that you put one or more inputs into and get one or more outputs from. That's it. These gates are all about input and output, and in Minecraft, as well as in digital logic, there's only two possible types of inputs and outputs—ON and OFF. Either your redstone is powered, or it isn't. That's all there is to it.
The models below are all made compact for convenience, but they can be spread out as much as you want, provided that you add enough repeaters. The important part is that all the connections remain intact, even if they're connected by long strings of redstone wire.
This one is a block with a switch on it and some redstone coming out the other end. You flip the switch on, the redstone turns on. You flip the switch off, the redstone turns off. There's a direct relationship between turning on the switch, and turning on the redstone.
If you've ever powered a redstone creation with a switch, this is the type of logic gate you used. See, you probably didn't know that you've already used a logic gate!
Now's where we start getting into weird, capitalized words like NOR, OR, AND, XOR, etc. Don't worry about them, because you don't have to memorize what each one does. That's what this guide is for, and I assure you that there's no test at the end!
A NOT gate is exactly the same as the simple Input/Output (also referred to as an I/O) gate above, except that the output is reversed. When you turn the switch on, the redstone turns off. When you turn the switch off, the redstone turns on. You use this if you have a mechanism that you want to always be on, except when you flip a switch. Like if you want pistons to be constantly extended until you flip the switch and then they pull back, you would use a NOT gate.
I personally don't find too much use for AND gates because I play on a Creative Server, but there are applications for everything. An AND gate will only turn on the redstone if both levers are in the on position. This means that you can have greater control over your mechanisms.
For example, say that you have one switch inside your home, and one switch outside your home and they both control the same door. If those two switches are connected by an AND gate, you can turn the switch inside your home off and no one outside your home will be able to get in, no matter how many times they flip the outside switch.
Now that's control!
This gate is really simple. Just two switches attached to a block with redstone coming out of it. The OR gate outputs the signal when either lever is turned on, regardless of the state of the other. When any switch is turned on, the power is turned on. So, the power only turns off when both switches are off.
Using the same door example from the AND gate, this OR gate would do the exact same thing, just with a reversed power output.
A NAND gate is essentially the exact same thing as an OR gate, but reversed. That is, when either switch is on, the power is off. Again, either switch can activate the redstone by being turned off, but it can only be deactivated if both switches are on.
This is useful when you want to make things like traps or doors, where you want the natural state of a piston to be on, and have it be able to be turned off at will by anyone on either side of the door.
A NOR gate looks just like an OR gate with an extra redstone torch, and its functionality is opposite. While an OR gate will output power when either switch is on, a NOR gate will output power only when both levers are off.
You would use this gate in similar circumstances to the AND gate, where you want to be able to control an outside switch from the inside. You would just use this one if you wanted the mechanism's at-rest state to be 'on' rather than 'off'.
Whoa, things are getting a lot more complicated! No, don't worry, it really hasn't. It just looks that way in the picture below. Follow the model in the picture or in the diagram at the beginning of this guide to make one of these, and I'll tell you what it does.
An XOR (usually pronounced ex-or) gate turns the power on only when one lever is off and one lever is on. Whether both switches are on or off, the power remains off. It's only when one switch is on and one is off that the redstone turns on.
This could be used if you wanted a door to be closed by pressure plates from the front or the back. If you wanted your piston-powered door to remain open until someone got close from either inside or outside, and then slam shut in their face, you would use an XOR gate. The natural state of a pressure plate is off, so if no one is standing on either of them, the power would be off. However, as soon as one person stepped onto the plate, it would turn on, closing the door. This alternately means that you could let anyone in by having someone stand on the inside and outside plates.
The XNOR gate turns the redstone on only when both levers are on, or both levers are off.
Remember our door-slamming example from the XOR gate? Well, let's say that you have a pressure plate outside and a switch on the inside, and they're connected to an XNOR gate. If you turn the inside switch on, then the power will only activate while someone is standing on the pressure plate. Alternately, if you flip the inside switch off, the power will activate until someone steps on the pressure plate. So you can easily control how your machine responds to someone stepping up to the plate, so to speak!
Okay, here's where things actually start to get complicated. All of the previous switches were straightforward input/output affairs. That is, given an input, your output would always be the same... they didn't change. The NOR latch changes.
A NOR latch can send power to two different outputs, whereas all the other gates we've dealt with have only had one output. However, the NOR latch will only send power to one output at a time. More complicated than that, the NOR latch will actually "remember" which switch you pulled last!
If you turn one switch off, the redstone power associated with that switch will turn on. Turn it on again, and the power will turn back off. However, while that switch is turned off and the power to it is turned on, no amount of flipping the other switch on the circuit will affect the power one way or the other. Only one switch can be active at a time. Only once you turn the power off on one side can the power be activated on the other. So the power can go back and forth between the two sides depending on how you flip your switches.
This latch is great for when you have two things that you want to happen, but you don't want them to happen at the same time, like an airlock. You never want both airlock doors to be open at the same time, so you have to close one in order to open the other.
The NAND latch is capable of sending power to both of its outputs simultaneously, unlike the NOR Latch. However, whichever output gets power first will retain it regardless of whether the switch is turned on or off. The power to that side will only turn off if the switch is off and the other is on. If one side's power and switch are both on, then the other side can be turned on and off at will.
This is a hard one to understand! Both sides can get power at the same time, but only one side can be turned off at a time. It's hard to conceptualize, but this is essentially the opposite of the NOR latch. This, too, could power an airlock, provided that the 'closed' state of the doors required constant power.
Where the latches are concerned, I strongly recommend that you build them and test them out for yourself before incorporating them into any of your builds. Being able to actually flip the switches and see what happens is really worth it for when you're trying to understand how these work.
This one is easy and fun! This will output to several different directions, and it will essentially freak out, turning on and off again over and over again in quick succession. This fun little guy is how we make things like machine guns or lights at a rave. If you need anything to flip on and off really quick, route it through one of these!
This specific example of the clock pulser is known as a 5-clock because of its five blocks (or repeaters). You can add as many blocks as you'd like to this chain, and it will change how quickly it pulses. These clocks are useful for an extremely wide variety of things, but the simplest of which is when you want something to happen over and over again, but at regular intervals.
For example, if you want a door to open and shut so that someone has to run through at just the right time or they get crushed, then a clock pulser is what you want!
Now that you understand what these basic logic gates do, I recommend that you make them for yourself and just experiment with them! Play with them and get a feel for them. The more you use them, the better ideas you'll have for how to incorporate them into your builds.
Above all, have fun with them!
If you still have any trouble with these logic gates, keep an eye out for our future in-depth tutorials dedicated to each specific type of gate.