Minecraft – How to delay an input for a short while after it turns off

minecraft-java-editionminecraft-redstone

I want to make a redstone device that prevents an input from turning on, then off, then on again very rapidly. For example, if a player turns a lever on, it should update instantly. However, if they turn it off, then turn it on again, the machine should stay off for a few moments before it turns back on. To put it another way, there should be a forced minimum delay between turning a device off then on, but no delay between turning the device on then off. Also, if the user turns the device off, waits the delay, then turns it on, the device should update instantaneously.

I have tried various approaches to this problem, and I assume I will have to use some kind of RS NOR Latch in combination with a series of repeaters for the delay, but I can't get it to function quite right. What's the best way to do this?

Best Answer

I managed to figure this one out. Here's a picture of the finished design:

Here's another picture of the same model:

Both of these images come from a compressed version of the device, but it's difficult to tell what's going on. Here's a much less compact version which is easier to understand. Keep in mind that the components are still the same in this version, just more spread out.

Here are the various components:

  • Red is the input.
  • Blue is a standard AND Gate.
  • Yellow is a falling edge trigger.
  • Green is simply a delay circuit.
  • Orange is a piston T Flip-Flop, as seen here in design M.
  • Purple is the output.

This works by using the T Flip-Flop as a "lock" to stop the input from going through the AND gate. The falling edge trigger creates a pulse when the AND Gate goes from ON to OFF, toggling the T Flip-Flop. The delay circuit then toggles the T Flip-Flop again, reopening the AND Gate.

The design can be fairly compact, but is a little slow. If speed is an issue, you could definitely speed it up by doing these things:

  1. Change the T Flip-Flop to an RS NOR Latch.
  2. Bypass the AND Gate when handling the input with the RS NOR Latch.
  3. Remove as many torches in the design as possible by using an inverted latch.

If speed is an issue and you can't figure out those modifications, I can try and add them to my design and post it. Just leave a comment. In my case, speed was not an issue, so I used this design instead. Take your pick.