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.


Solution 1:

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.

showing off a binary counter
(source: xooimage.com)