# GuideA reference guide for simple logic devices

#### DRKV

##### Duke Fishron
I have compiled a little guide that demonstrates the function of various simple logic gate devices. You can combine these in different ways to create all sorts of mechanisms. I constructed the guide in a “logical” order, first walking you through the most basic concepts, and then building up more complicated setups.

Before reading this, you should be familiar with how logic gates and wiring works in general. If you're in doubt, I recommend you read: [Guide] Logic Gates: Order of Operations, Smoke and how to prevent it

I have 3 images for each device. A gif demonstrating usage in real time, a picture with the wires shown, and a step-through I did using MechScope.

As a side note: all of the gates I used here are AND gates. You really don’t need the others too often…

Signal manipulation
Diodes

Single lamp diodes are often used for purposes such as:
• Transferring a signal to a different wire color
• “Delaying” a signal by one logic gate execution step to change to order in which other gates get triggered
• Controlling the direction of signals, acting as a diode
• Limiting the number of signals that pass through (more on this later)

Timer delay

This setup lets you delay a signal by up to 5 seconds. You generally can’t make a timer just turn itself off, so here we trigger a logic gate, which in turn will switch the timer off.

The doubler

Logic gates will only trigger once per wiring iteration. If their output value is change again, they will just emit a puff of smoke and nothing else will happen. This can be abused to make all sorts of logic possible. Here, we use them to immediately generate a second signal if the red wire gets triggered. Two consecutive signals like can be very useful to get other logic gates to do what you want them to.

Limiting signals

Running a doubled signal (or pretty much any number of signals) through a diode will only let the first one through, turning it back into a single signal.

Tripler

You can combine signals from different logic gates to get more triggers. This setup will triple the input.

Transistors

In terraria’s signal based wiring, Boolean AND gates are not necessarily very useful. What we really want, is the ability to kind of “gate” a signal. Let it through at certain times and stop it at others. You can’t achieve this in terraria with just a simple AND gate. For instance, if your “gate” and your “trigger” lamps are both ON, switching the gate OFF will create an output, which we don’t want.

Faulty transistor

Faulty gates, when their faulty lamp is triggered, will generate a signal with a probability determined by the ration of ON gates to OFF gates. If the lamp here is ON, we get an output with a 1/1 chance, when it’s OFF we get it with a 0/1 chance. This effectively acts as a transistor. The state of the lamp (the base) determines whether the signal can pass from the faulty lamp (the collector) to the gate’s output (the emitter).

Smoky transistor

There is another way to create transistors. The problem with using just AND gates, is that the state of the collector lamp will affect its behavior. When the lamp is OFF things are fine, but once you turn it ON, toggling the base can cause problems… So let’s just keep the collector OFF… By doubling the input signal before sending it to the collector, we immediately switch the collector lamp OFF after it turns ON. We don’t get a second output signal by doing this, because the two triggers both happened in the same iteration. The second one will only emit a puff of smoke.

The big advantage of smoky gates, is that you can add multiple lamps to it, to AND them together. With faulty transistors you need to add an additional AND gate for that.

Simple devices
Reset switch

This device can be used to reset a toggleable device to a certain state. Once the transistor is triggered, it will turn its own lamp OFF and whatever is attached to it as well.

Reset switches can be easily stacked next to each other to create compact designs.

Inline reset switch

This is a different reset switch that relies on smoky logic instead of faulty gates. Their big advantage, is that you can run a wire straight across them vertically. This allows this setup to have the switches above the gates instead of having them on the bottom.

Signal based NOT gate

So, a traditional NOT gate makes pretty much no sense in terraria. Wires don’t have a state, so there is nothing to negate. This little thing is what I would call a signal negator. It creates an output, if the top input is triggered without triggering the input on the side first. You can make something happen, if something has NOT happened before triggering it.

Flip-Flop

Again, this is not really a flip-flop in a traditional sense. It will switch the input to two different outputs. First to the left, and then to the right.

Reset-Set

Triggering one of the inputs will toggle the output. Hitting that same input again will do nothing, you have to use the other one instead, which will then also block and you need to hit the first one again. This can be used set up something to only happen once, like a pitfall trap, but you can also add a reset switch to them.

You can also hook up two different outputs to this one, like with the flip-flop.

Binary counter

Just like the name suggests, these devices will gradually increment a number in base two. This can be useful if you want to wait until something, like a timer for instance, has triggered some number of times.

Divide by two

The main idea behind these, is to make a gate, that will only output once for every second signal it receives.

The counter

Once you can divide a signal by two, you can also divide it by 4, 8, 16 and so on. You can just chain these dividers together, to translate the number of pulses the devices received, into a binary number.

Shift register based counters

Quite often you want to send a signal from a wire to different devices, one after the other. You can use this to do all sorts of things, like to make scrolling light displays, wait for some number of inputs, or to “move” a light or selection left or right.

The shift register

All you need to do, is link up a bunch of self-resetting transistors to each other’s enable lamps, and common the triggers together.

You’ll notice, that the lights hooked up to the output of the device don’t really seem to “shift”. (It kind of looks like the output of a Johnson counter.) That is because we are only sending one signal to each of them. We also want to turn them OFF, once the next output is triggered. So all we have to do, is hook up the output of two consecutive segments to each torch.
You can also connect the end of the counter to the beginning to create a circular counter.

If you want to connect this up to something more complicated, you should switch the torches for some diodes, and then you only have to run one wire per stage to your output.

Sequencer

If you hook up different inputs to all of the segments on the shift register, you can use it to check if something happened in a certain order. You can use this to make a simple password lock mechanisms.

Compact resettable counter

You can skootch the segment of the counter closer, but then you need to use three different wire colors. This also makes wiring anything useful to it quite difficult, but you can still use it for a timer. We can however easily connect a reset array to it, thanks to the inline reset switch.

(As a side note, using these counting and signal doubling techniques, it is possible to shove multiple signals down a single wire. I think this is a very interesting idea, that is worth checking out: PC - Serializing data - save wire, space and nerves)

Conclusion
Now you can just put a bunch of these devices together to create some more interesting things. For instance, here is a simple little password lock. (As you can probably tell, I kinda like password locks…)

You can then, instead of hard wiring the code, add in some extra transistors to check if the right digit was entered. Then have a way to reprogram those transistors to change code. Then maybe add a more elegant reset mechanism and some kind of different way of entering the code, and you get something like my Reprogrammable rotary lock: PC - [Showcase] Reprogrammable rotary lock Same idea, jut scaled up.

Last edited:

HUGE

#### BrusselSprouts693

##### Retinazer
https://imgflip.u/i/36x57o
Really great contraptions. It seems like teal pressure pads can do quite a few of them, but they each have things not done by the other. Of course, they seem to use each other quite a bit. Tp put it briefly, well played, Logic gate person. I hope you figure out something fancy.

#### DRKV

##### Duke Fishron
https://imgflip.u/i/36x57o
Really great contraptions. It seems like teal pressure pads can do quite a few of them, but they each have things not done by the other. Of course, they seem to use each other quite a bit. Tp put it briefly, well played, Logic gate person. I hope you figure out something fancy.
I'm not a huge fan of the whole teal-pad-dart-trap thing, mostly just because of the cooldowns, and how slow they are in general. Though, stuff like this, is pretty difficult to beat: PC - [Question] Weird Mechanics of Dart Traps and Teal Pressure Plates

#### Loan_Shark

##### Terrarian
Hey, I got a little issue with something i'm trying to do here, and I thought you could help me out: I'm trying to synchronize the fireplace and chimney so when I turn the fireplace on, the chimney turns on. The problem is that the fireplace has 2 states (on/off) and the chimney has 3 (off/no smoke particles/yes smoke particles). It looks like the devices you made here are the right thing for the job, but I don't know how to put them together. Can you maybe send me a screenshot of a wiring mechanism that could help me? Thanks.

#### pbq

##### Terrarian
Something like this

#### Loan_Shark

##### Terrarian
Thanks! I got it to work. But just one more thing: This one seems to only switch from off to no particles. Do you think you can make one that switches only from "off" to the "particle effect" state, skipping the "on with no particles state"?

#### pbq

##### Terrarian
From the on state, fireplace and smoke(no particles):

Flick the switch, both should be off now and lamp in the on state:

Pickaxe the on lamp to remove it and the faulty lamp above it:

Flick the switch, state should be fireplace and smoke(no particles) again:

Place the lamps back on, state should become fireplace and smoke(particles):

Should be done now.

This is turned out into a kind of an interesting lesson/example for me on why you don't make changes to electrical circuits with the power still on. Changing this would have been so much easier with adding more temporary switches to change states and cutting wires so changes to circuit don't affect the operated devices, but I figured that'd be more annoying to step by step

#### Loan_Shark

##### Terrarian
From the on state, fireplace and smoke(no particles):
View attachment 230373
Flick the switch, both should be off now and lamp in the on state:
View attachment 230374
Pickaxe the on lamp to remove it and the faulty lamp above it:
View attachment 230375
Flick the switch, state should be fireplace and smoke(no particles) again:
View attachment 230376
Place the lamps back on, state should become fireplace and smoke(particles):
View attachment 230377
Should be done now.

This is turned out into a kind of an interesting lesson/example for me on why you don't make changes to electrical circuits with the power still on. Changing this would have been so much easier with adding more temporary switches to change states and cutting wires so changes to circuit don't affect the operated devices, but I figured that'd be more annoying to step by step
Wow, thanks! Terraria electrical mechanics seem a lot more complicated to me compared to minecraft redstone. I wish I understood how this stuff worked.

#### ACHKA1

##### Terrarian
hey is he still alive or not but my world wont load anyore can you help me

#### MicaelJarniac

##### Steampunker
Missing the `B` `A` at the end...