Redstonery
RedstoneryCircuits › RS latch
Memory circuit

RS latch

Remember which of two requests happened last.

8 × 3 footprint1 layer14 blocksTested in 4 rotationsJava Edition 26.2
Open in the simulatorBuild it in the game

Layout

Layer 0 (on the floor)
lever [face=floor, facing=north, powered=false] at x 0, z 0redstone dust at x 1, z 0redstone lamp at x 2, z 0redstone torch (on a wall) [facing=east] at x 3, z 0redstone dust at x 4, z 0redstone lamp at x 5, z 0redstone dust at x 6, z 0lever [face=floor, facing=north, powered=false] at x 7, z 0redstone torch (on a wall) [facing=south] at x 5, z 1redstone dust at x 5, z 2redstone dust at x 4, z 2redstone dust at x 3, z 2redstone dust at x 2, z 2redstone dust at x 2, z 1
redstone dustredstone torchinputlamparrows point where a device sends its output; north is up

How it works

Two torches, each on a lamp the other powers through dust: whichever was put out last stays out. Pulse the right lever to set Q, the left one to reset Q. Release each lever after use. Both inputs on is an invalid operating combination: release one to choose the retained state. The lamps show Q and its opposite.

  1. Cross-coupled outputs feed back into the opposite side, allowing a state to remain after an input pulse ends.
  2. Use separate set and reset controls, then release them to observe the stored state.

Inputs and outputs

  • Inputreset (x 0, y 0, z 1)
  • Inputset (x 7, y 0, z 1)
  • OutputQ (lamp) (x 5, y 0, z 1)
  • Outputnot Q (lamp) (x 2, y 0, z 1)

Blocks you need

8 × redstone dust, 2 × lever, 2 × redstone lamp, 2 × redstone torch (on a wall).

Build it in the game: 14 commands

Relative to where you stand, with x running east and z running south. Paste one line at a time into chat, or into a chain of command blocks. The block art is the game's own; the layout is what the page above shows.

setblock ~0 ~0 ~1 minecraft:lever[face=floor,facing=north,powered=false]
setblock ~1 ~0 ~1 minecraft:redstone_wire
setblock ~2 ~0 ~1 minecraft:redstone_lamp
setblock ~3 ~0 ~1 minecraft:redstone_wall_torch[facing=east]
setblock ~4 ~0 ~1 minecraft:redstone_wire
setblock ~5 ~0 ~1 minecraft:redstone_lamp
setblock ~6 ~0 ~1 minecraft:redstone_wire
setblock ~7 ~0 ~1 minecraft:lever[face=floor,facing=north,powered=false]
setblock ~5 ~0 ~2 minecraft:redstone_wall_torch[facing=south]
setblock ~5 ~0 ~3 minecraft:redstone_wire
setblock ~4 ~0 ~3 minecraft:redstone_wire
setblock ~3 ~0 ~3 minecraft:redstone_wire
setblock ~2 ~0 ~3 minecraft:redstone_wire
setblock ~2 ~0 ~2 minecraft:redstone_wire