The second project in THE SIX – An exploration into Redstone.
Computers often seem like magic, but they’re actually not! Inside of them are millions or billions of circuits ticking away, some small and some large, that control exactly how your computer runs. In computer science classes, we often abstract most of this complexity away, but in this blog post series I would like to explore some of these circuits in quite a fitting medium – Minecraft, which provides an intuitive graphical way to construct these circuits via redstone.
I’ve designed these blog posts so you can follow along in my journey and design along with me! A huge, huge thanks to MattBatWings & CraftyMasterman, two redstone YouTube creators whose videos I often followed when myself I got stuck. Many of the builds in this post are from their videos. The blog posts assume you have a basic understanding of logic gates and boolean algebra, binary and hexadecimal number systems, and a dash of previous experience in Minecraft wouldn’t be a bad idea.
So, where do we begin?
If you’re following along, make sure you have Minecraft 1.18.2 installed on your system, and create a new creative world. For the settings of the world, I’ve provided a template below you can unzip and use. I’ll also be using this texture pack which, although optional, I highly recommend.
This is what your world should look like after creation. If you have any problems setting up, leave a comment below!
Now I would like to explain some of the simpler redstone components.
Basic Components
First, let’s take a look at redstone dust. This is like an electrical wire – it carries a power and signal from one place to another. When it is dark red, like shown below on the left, it is OFF
, and when it is bright red, as shown on the right, is ON
. Here, I’m using a lever to power the redstone dust.
Redstone dust can be powered by a variety of blocks, including redstone blocks, observers, levers, buttons, and more. Dust can be placed on solid blocks and transparent blocks (like glass).
Redstone dust can be connected to other redstone dust in a line. The number on the dust (shown by the texture pack) tells us how much power it has, from 15
being full powered to 0
being unpowered (aka it’s OFF
again). For every new connected block in a line, redstone dust loses one power level, meaning after 15
blocks, the line runs out of power.
If we want to power the dust more than 15 blocks, we can use the repeater, which returns the power of the redstone dust in front of it to 15
, in exchange for a delay of 1
– 4
tenths of a second depending on how we configure it. Note that tenths are often called ‘ticks‘.
Below is a video of a repeater with 4/10
s delay. Notice how the dust in front of it powers ON
then OFF
a short time after the lever is flicked:
The comparator like the repeater can also be placed on blocks. It has two modes – compare mode and subtract mode.
In compare mode, the comparator’s third dot is not lit. The comparator checks which redstone power level is higher – the signal behind it, or the signal to either side. Here, the signal behind it is 14
and to the left 13
, so the comparator outputs a signal of 14
in front of it.
If we turned the lever on the right on, it would supply a signal of 11
– and as 11 < 14
, this wouldn’t change the output of the comparator.
Compare mode is used less frequently than subtract mode, but still can be useful for certain applications.
In subtract mode, we have pressed the third dot and it is lit. The comparator here takes the signal in the back – 14
– and subtracts the higher of the two sides, in this case 11
, and outputs the result 3
in front of it.
Turning the lever on the left on here would supply a signal of 13
meaning that the comparator would output 1
instead, as 13 > 11
.
As you can imagine, this component is very useful when doing numerical (binary) calculations using redstone.
The comparator can also read from containers – an example is a barrel that is around half full of items, shown below. The comparator then outputs a signal strength proportional to how full the barrel is, in this case 7
.
And finally for this section, the redstone torch. The redstone torch can be placed on the side of blocks or, less commonly, on top of blocks. They give off full power to blocks beside, above and beneath them, but not the block they are attached to.
By powering the block they are attached to, the redstone torch becomes unpowered and does not give off power anymore.
This essentially inverts the redstone signal. With this knowledge, you might realise you could make a setup to make a redstone torch invert itself, by placing a block above it, then a dust next to the block.
You probably don’t want this to happen in your redstone builds, as this can lead to the torch burning out, which turns it OFF
until it gets an update, such as breaking the block above it.
That’s all the basics components. But what about blocks?
Blocks
In the redstone world, blocks can either be hard powered or soft powered. In this quick section, I’ll show hard powered blocks as red and soft powered blocks as orange.
Soft powered blocks include blocks which redstone dust is sitting on or runs into.
Hard powered blocks include blocks which repeaters run into, redstone blocks, levers, pretty much every other component.
Both soft and hard powered blocks can conduct redstone components next to them, such as pistons, lamps (the light in the image), repeaters, comparators, depowering torches, and the like.
The main difference is that soft powered blocks will not activate redstone dust lying around it, whereas hard powered blocks will do so.
Redstone blocks (hard) power the blocks next to them. Buttons do what levers do, but only temporarily – a stone button provides power for 10
ticks/tenths of a second, and a wooden button provides power for 15
ticks.
These are commonly used for inputting into redstone components, or starting a circuit running.
Buttons and levers can only be flicked by players. Pressure plates can be stepped on by most entities, though you don’t see them that commonly.
A note – lamps take 2
ticks to turn OFF
, although they turn ON
instantly. This is quite annoying, but trapdoors do not have this property, and turn OFF
instantly. The texture pack in the beginning, provided by MattBatWings, actually retextures trapdoors on the side of blocks to look like lamps due to this, which you will quickly realise if you have sound on!
This is so we can always have the correct reading of a redstone circuit, without having to wait the 2
ticks that lamps take to turn OFF
, because during that time their reading will be wrong.
And that concludes the blocks section!
Logic Gates
We can construct logic gates using the components in the previous section. Recall the truth tables for AND
, OR
, and NOT
:
For NOT
, we can use the nifty property of redstone torches inverting to create this circuit. When the input is OFF
, the output is ON
, and when the input is ON
, the output is OFF
. The output is the negation of the input. It’s also possible to create this circuit in other ways, though this is the simplest.
For OR
, it’s even simpler, as either redstone wire – input #1 or input #2 – will power the output ON
. Redstone dust just has this property by default.
As for the AND
gate, we require two torches to negate the inputs, and a redstone dust between them. The third torch, placed on the block with the dust on top, will only ever turn ON
if the two other torches are turned OFF
by our inputs, which will depower the redstone dust allowing for the third torch to turn on.
In the image below, input #1 is turned ON
, but input #2 is turned OFF
, so the gate output is OFF
.
Other, more complicated gates, like XOR
, NOR
, NAND
and XNOR
, can be built using combinations of these three. As an exercise, try finding out what combination you need, then building them!
Binary Addition
Time for our final circuit in this blog post – an adder!
I hope you remember how to add two binary numbers together! To check, here’s an exercise – what is 11001011 + 00111010
? It’s 100000101
. We can construct an adder using our circuits. Like the logic gates, it’s helpful to define inputs and outputs in a truth table.
As you know, in binary addition, we deal with two bits – one from each number – in a column. Let’s call these A and B, and they are either 0
or 1
. These are our inputs.
Our outputs are the sum bit of A and B, which can also be either 0
or 1
, and the carry bit – 1
if both A and B are 1
– to carry to the next column. The truth table below sums this up. (badumpsh)
If we compare this table to our previous gates, the carry bit matches the AND
table and the sum bit matches the XOR
truth table. So using those, we can build the half adder circuit, as shown below. Let’s investigate this in detail.
On the left is input A and on the right is input B. Each of the inputs run to both of the circuits – the orange circuit being the AND
gate, that leads into the carry, and the comparators and green block being a compacted version of a XOR
gate, that leads into the sum. The yellow blocks are just there to bridge input A over into the XOR
gate circuit.
In the video below, we run through our truth table by toggling the A and B input levers and see it matches the output section.
This circuit is great if you only want to ever add 0 + 0
, 1 + 0
, or 1 + 1
. But what if we wanted to do column addition?
Then, we need a full adder, which can be made by combining two half adders and an 0R
gate:
We have a third input – the carry in from a previous bit, and retain our two outputs of a carry and a sum. This allows us to chain multiple full adders together, like you would when adding longer binary numbers.
In the next post, we will compact this adder down and create an 8-bit adder, then use similar methods to create an 8-bit subtractor!
I hope you enjoyed, and see you in the next blog post (ᵔ◡ᵔ)
Redstone is awesome I only wish I ever learned how to do it :,(