Exploring logic gates in Minecraft

By Martin O'Hanlon. Posted

Figure 3 A night light which uses a NOT gate to turn on a lamp when it gets dark

Originally published in Hello World: The Big Book of Computing Content, Oct 2022. All information true at the time of original publishing.

Logic gates can be difficult to visualise, and it can be tricky to understand why they are useful in the real world. They are often described as black boxes; their operations being entirely abstract, with the output being the only indication of their function. Minecraft (minecraft.net) is a brilliant tool that can help bring logic gates to life for you and your learners, providing a sandbox to create logic gates from simple components, understand their operation, and connect them to outputs in a virtual world before exploring how they react to inputs.

Building circuits in Minecraft

Before looking at logic gates, it’s important to first understand how you can create circuits and transmit binary signals in Minecraft. In the real world, circuits are created by using wires to conduct electricity, and the presence of an electrical voltage (meaning there is electricity flowing through the circuit) indicates that the output is 1, or on. In Minecraft, circuits are created using ‘redstone dust’, a material used to conduct power (see Figure 1), and as in the real world, electricity flowing through the circuit indicates that the output is 1, or on. Input devices in Minecraft (for example, buttons, switches, and pressure plates) generate power that can be transferred to output devices (for example, lamps, doors, and dispensers). For instance, connect a switch to a lamp block using redstone dust and turn the switch on; power is conducted through the redstone dust and the lamp turns on (Figure 1).

Figure 1 The power from the switch transfers through the redstone dust and turns the lamp on

In addition to redstone dust and input and output devices, there are also components for making more sophisticated circuits, such as redstone torches, repeaters, and comparators. Redstone torches are essential for creating logic gates, as they are not only a source of power, similar to a battery, but they can also invert a signal (for example, if the power is on, the torch will be off, and vice versa). This ability to act like a switch allows you to use redstone torches in similar ways to transistors, the basis of all logic circuits.

Constructing logic circuits

By connecting redstone dust and redstone torches together in the right configuration, you can create logic gates. The simplest logic gate is a NOT gate whose output is the opposite of the input (for example, if the input is on, the output is off). This can be produced using a redstone torch to invert the input (Figure 2).

Figure 2 A switch is mounted on a block and connected to a lamp via a redstone torch; when the switch is off, the lamp is on, and vice versa

A practical example of the use of a NOT gate is to create a night light. You can do this by connecting a daylight detector (which is powered when the sun is up) to a lamp via a NOT gate (Figure 3 above). At night, the daylight detector will be off; the NOT gate will invert this signal and turn the lamp on.

You can also create OR, AND, and XOR gates using redstone torches, dust, and blocks (Figure 4):

  • An OR gate is simply the connection between two inputs. When either or both inputs are on, the output is also on.

  • An AND gate’s output is on when both inputs are on. To create an AND gate, you need to use two redstone torches to invert the input connected to a third redstone torch, which will output on when both inputs are also on.

  • An XOR (exclusive OR) gate’s output is on when either input is on, but off when both inputs are on. The layout of the XOR gate with redstone is more complicated, needing seven redstone torches connected together. This mirrors the complexity of constructing an XOR from NOT, OR, and AND gates.

Figure 4 NOT, OR, AND, and XOR logic gates created in Minecraft

Investigating how these gates work, and seeing the interaction between the input switches and the lamp, can help learners develop an understanding of each gate’s operation and act as an engaging introduction to truth tables.

Connecting the Minecraft world

Using these logic gates and different input and output devices in Minecraft, you can create realistic devices, for example, a door that can only be opened by two players at the same time by using two buttons connected to a door via an AND gate (Figure 5). This is also an excellent opportunity to introduce logic circuit diagrams, connecting the abstract to the concrete (see the diagram in the top left of Figure 5).

Figure 5 An AND gate is used to create a door that can only be opened by two players working together

Multiple logic gates and circuits can also be linked together to create more complex devices. Take some time to look through the different input and output blocks and components in Minecraft, and let your imagination guide what you create. You may also find it useful to create a logic circuit diagram before embarking on your build.

While writing this article, I experimented myself, and created an alarm that beeps when one of my sheep in the Minecraft world leaves its pen. The alarm is automatically activated at night, but also has a switch so I can also turn it on manually during the day (Figure 6).

Figure 6 You can create more complex circuits, such as this automatic sheep alarm, by linking multiple gates together

Minecraft and its redstone give you the opportunity to play and experiment with logic gates and circuits, without being constrained by the physicality of creating actual electrical circuits. I hope you have as much fun as I did!

A redstone computer

A redstone computer

Fully functional computers have been created using redstone in Minecraft by building on top of logic circuits like those introduced in this article.

There are some very impressive builds, including this quad-core computer with user interfaces and displays (helloworld.cc/minecraftcomputer).



Free - UK only

If you’re a UK-based teacher, volunteer, librarian or something in between, we'll send each issue free to your door.



Just want to read the free PDF? Get each new issue delivered straight to your inbox. No fuss and no spam.


From £6

If you’re not a UK-based educator, you can buy print copies from our store.