# Is it possible to create a counter just with wiring?

With the new logic gates in the 1.3.1 update, is it possible to create some wiring circuit that counts how many times a trigger was activated? In other words, is it possible to make a circuit that outputs a trigger every two input triggers?

I've done some experimenting but the nature of wires and there being no intrinsic on/off state in Terraria makes it pretty counter-intuitive compared to real world logic circuits.

## 1 Answer

Something like this :

``````                     +--F                 (wire I crosses F and O)
Input (wire I) ------+--O                 (wire O crosses G)
G----- Output (wire O =/= wire I, in terms of color)
``````
• F : faulty logic lamp (sold 2 gold, ouch !)
• O : regular logic lamp (on, or off, doesn't matter)
• G : any logic gate (OR, AND, NOR, NAND, XOR, XNOR)

The faulty logic lamp overwrite the current gate to a "random access gate" (turns blue, and is the same "blue gate" from any other gate).
But with only 1 lamp below it, it has only 2 states upon the faulty lamp receiving Input :

• if the normal lamp below is ON : the blue gate always outputs (1/1 = 100% probability)
• if the normal lamp below is OFF : the blue gate never outputs (0/1 = 0% probability)

So if the exact same input that uses the faulty lamp cross the regular lamp, the resulting gate produces a tick that happens one input tick out of 2, in a periodic fashion.

This has now been verified. The gate outputs a signal only if the Input sets the lamp to ON. It is a way to detect an "upfront" signal.

Note : if you short-circuit the gate and the lamp, no more signal will be taken into account, and you cannot use a junction box, you have to use a different color between the input and the output.

Example of a binary counter.

(source: xooimage.com)

• Could you explain how the Faulty Lamp works? I always thought it would simply randomly decide to be on or off with every pulse it received. Commented May 24, 2016 at 15:45
• @DanmakuGrazer This can even be a full fledged question, in my opinion, as quite a lot can be said on the subject :) Commented May 24, 2016 at 15:50
• @DanmakuGrazer In short, probability of output is lampsON / totalLamps. Commented May 24, 2016 at 15:56