I want to build a circuit that has a single output from two inputs. The output can be activated when both inputs are true, but once activated it will maintain its state while either input is true. Only once BOTH are false does the output turn false.

My use case for this is a button-activated chest unloader. When the button is pressed, it will empty the chest until the chest is empty. Then it will deactivate.

What I tried to do was a logic gate input into a T Flip Flop gate that looked like:

TFlipFlipInput = (chest && button) || !chest

This almost works, but there's undesired behavior like manually emptying the chest toggles it, or pressing the button a second time will toggle it off.

  • "pressing the button a second time will toggle it off." - that's a feature – John Dvorak Apr 28 '20 at 14:41
  • Hah that would be acceptable, but emptying the chest manually is really the big issue. This is for a garbage disposal, so if the output is left in the ON state with nothing in the chest, it would immediately start dispensing stuff from the chest on the next use, without a button press. This would be dangerous. – Larry Rubin Apr 28 '20 at 14:50
  • Actually, I suppose I could do something like TFlipFlipInput = (chest && button) || (!chest && TFlipFlipOutput) that would only allow an empty chest to turn the output to the off position. I'm still curious if there's a simpler way. – Larry Rubin Apr 28 '20 at 15:06
  • I've made a absurdly complex functional prototype out of a D-Type Latch and a bunch of gates, found here. I'm certain this can be simplified. – Corsaka Apr 28 '20 at 15:13
  • I'm not well versed in Redstone, but unloading = button || (chest && unloading) should work just fine – John Dvorak Apr 28 '20 at 15:17

When I read the question, I quickly thought that a memory cell could be involved somewhere in the solution. But actually, a memory cell (with one input inverted) is already all you need!

Imagine that the comparator comes from your minecart and the button is just your button. The redstone lamp is the output for emptying the minecart.

When the minecart arrives with items, it turns on the comparator, which turns off the redstone lamp on the left and the redstone dust. Nothing else happens, because the memory cell still holds its state, that's the point of a memory cell.

When you now press the button, the bottom redstone torch and the left repeater turn off, which allows the top right redstone torch to turn on (since it's also not deactivated by the redstone line anymore), which turns on the output and the repeater on the right.

When the button input ends, the bottom redstone torch still does not turn on, because the right repeater is still on. Again, what a memory cell is supposed to do.

Only when the comparator turns off and the left redstone torch and the dust turn on again, then the top right redstone torch turns off again, deactivating the right repeater, activating the bottom redstone torch and the left repeater.

Special cases:

  • If the minecart empties before the button turns off, the input turns off rightaway (with 3 ticks delay).
  • If you press the button while the minecart is empty or not there, nothing happens.
  • Spamming both inputs in certain ways very quickly and very often might cause the torches to burn out, but that should be extremely unlikely in your usecase and probably very easy to fix (it might even fix itself).

Let's re-frame the problem a bit. What you're really looking for is a garbage disposer, which has a button for turning it on, and an auto off feature when it's disposed of all the items. A T-Flip Flop is not the best thing for this, as it has only a single input.

I would use use a RS-Nor Latch in this case. You can keep the reset line high whenever the chest is empty (simple not gate), meaning that pressing the on button won't even do anything. When the chest has any items, the reset line will be low, and sending the set line high (by pressing the button) will trigger the latch output to go high, initiating the garbage disposal process.

The advantage of this is that this can be made fairly compact. Typical implementations of RS-Nor Latches are smaller than T-Flip Flops, which themselves can be smaller than piston based D-Latches (repeater D-Latches are still smaller than both, but IMHO aren't appropriate here).

  • Ahh, this works, and it's much more compact! Thanks! – Larry Rubin Apr 28 '20 at 16:44

enter image description here

Here's an example of something that would work.

The main part of this is a D-Type Latch, which is triggered at first ONLY when both are on, and once in this on state, triggered ONLY when both are off.

By replicating this gate system in minecraft and replacing the inputs/outputs you should be good to go.

  • I started looking into a D-Type Latch after I read your comment, and it looks like this "D Flip Flop" might work? youtube.com/watch?v=6Lfpaq4UGD4 – Larry Rubin Apr 28 '20 at 15:35
  • @LarryRubin Yes, a D-Type Latch and D-Type FlipFlop are essentially the same thing; the minor difference in them makes no difference here. As long as you power the right block with the right input, it should function fine – Corsaka Apr 28 '20 at 15:42
  • I've modified the inputs slightly from the video, and I've got something that's decently compact and works! Awesome. Thanks for your help! – Larry Rubin Apr 28 '20 at 15:53

enter image description here

Hopper pointed into dropper, dropper into hopper, one non-stackable item in the dropper. You can skip one set of repeater-dust-block if you want to give only one of the inputs the ability to keep the output active.

From logic point, that's an AND gate and an RS latch with negated R input (absence of signal at R resets.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.