Redstonery
RedstoneryCircuits › 2-to-4 decoder
Logic circuit

2-to-4 decoder

Translate a binary input pattern into a selected line.

25 × 17 footprint4 layers207 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 dust at x 2, z 0redstone dust at x 3, z 0redstone dust at x 4, z 0repeater [facing=west, delay=1] at x 5, z 0redstone dust at x 6, z 0redstone dust at x 7, z 0redstone dust at x 8, z 0redstone dust at x 9, z 0redstone dust at x 10, z 0repeater [facing=west, delay=1] at x 11, z 0redstone dust at x 12, z 0redstone dust at x 13, z 0redstone dust at x 14, z 0redstone dust at x 15, z 0redstone dust at x 16, z 0repeater [facing=west, delay=1] at x 17, z 0redstone dust at x 18, z 0redstone dust at x 19, z 0redstone dust at x 20, z 0redstone dust at x 21, z 0redstone dust at x 22, z 0repeater [facing=west, delay=1] at x 23, z 0redstone dust at x 24, z 0repeater [facing=north, delay=1] at x 2, z 1redstone dust at x 2, z 2redstone dust at x 2, z 3redstone dust at x 2, z 4redstone dust at x 2, z 5redstone dust at x 2, z 6redstone dust at x 2, z 7redstone dust at x 2, z 8repeater [facing=north, delay=1] at x 2, z 9stone at x 4, z 4redstone dust at x 4, z 5redstone dust at x 4, z 6redstone dust at x 4, z 7redstone dust at x 4, z 8repeater [facing=north, delay=1] at x 4, z 9redstone dust at x 2, z 10redstone dust at x 3, z 10redstone dust at x 4, z 10redstone dust at x 3, z 11stone at x 3, z 12redstone torch (on a wall) [facing=south] at x 3, z 13repeater [facing=north, delay=1] at x 3, z 14redstone dust at x 3, z 15redstone dust at x 3, z 16redstone dust at x 4, z 16redstone lamp at x 5, z 16repeater [facing=north, delay=1] at x 8, z 1redstone dust at x 8, z 2redstone dust at x 8, z 3redstone dust at x 8, z 4redstone dust at x 8, z 5redstone dust at x 8, z 6redstone dust at x 8, z 7stone at x 8, z 8redstone torch (on a wall) [facing=south] at x 8, z 9stone at x 10, z 4redstone dust at x 10, z 5redstone dust at x 10, z 6redstone dust at x 10, z 7redstone dust at x 10, z 8repeater [facing=north, delay=1] at x 10, z 9redstone dust at x 8, z 10redstone dust at x 9, z 10redstone dust at x 10, z 10redstone dust at x 9, z 11stone at x 9, z 12redstone torch (on a wall) [facing=south] at x 9, z 13repeater [facing=north, delay=1] at x 9, z 14redstone dust at x 9, z 15redstone dust at x 9, z 16redstone dust at x 10, z 16redstone lamp at x 11, z 16repeater [facing=north, delay=1] at x 14, z 1redstone dust at x 14, z 2redstone dust at x 14, z 3redstone dust at x 14, z 4redstone dust at x 14, z 5redstone dust at x 14, z 6redstone dust at x 14, z 7redstone dust at x 14, z 8repeater [facing=north, delay=1] at x 14, z 9stone at x 16, z 4redstone dust at x 16, z 5redstone dust at x 16, z 6redstone dust at x 16, z 7stone at x 16, z 8redstone torch (on a wall) [facing=south] at x 16, z 9redstone dust at x 14, z 10redstone dust at x 15, z 10redstone dust at x 16, z 10redstone dust at x 15, z 11stone at x 15, z 12redstone torch (on a wall) [facing=south] at x 15, z 13repeater [facing=north, delay=1] at x 15, z 14redstone dust at x 15, z 15redstone dust at x 15, z 16redstone dust at x 16, z 16redstone lamp at x 17, z 16repeater [facing=north, delay=1] at x 20, z 1redstone dust at x 20, z 2redstone dust at x 20, z 3redstone dust at x 20, z 4redstone dust at x 20, z 5redstone dust at x 20, z 6redstone dust at x 20, z 7stone at x 20, z 8redstone torch (on a wall) [facing=south] at x 20, z 9stone at x 22, z 4redstone dust at x 22, z 5redstone dust at x 22, z 6redstone dust at x 22, z 7stone at x 22, z 8redstone torch (on a wall) [facing=south] at x 22, z 9redstone dust at x 20, z 10redstone dust at x 21, z 10redstone dust at x 22, z 10redstone dust at x 21, z 11stone at x 21, z 12redstone torch (on a wall) [facing=south] at x 21, z 13repeater [facing=north, delay=1] at x 21, z 14redstone dust at x 21, z 15redstone dust at x 21, z 16redstone dust at x 22, z 16redstone lamp at x 23, z 16
Layer 1 (1 up)
stone at x 4, z 3redstone dust at x 4, z 4stone at x 10, z 3redstone dust at x 10, z 4stone at x 16, z 3redstone dust at x 16, z 4stone at x 22, z 3redstone dust at x 22, z 4
Layer 2 (2 up)
stone at x 0, z 0stone at x 1, z 0stone at x 2, z 0stone at x 3, z 0stone at x 4, z 0stone at x 5, z 0stone at x 6, z 0stone at x 7, z 0stone at x 8, z 0stone at x 9, z 0stone at x 10, z 0stone at x 11, z 0stone at x 12, z 0stone at x 13, z 0stone at x 14, z 0stone at x 15, z 0stone at x 16, z 0stone at x 17, z 0stone at x 18, z 0stone at x 19, z 0stone at x 20, z 0stone at x 21, z 0stone at x 22, z 0stone at x 23, z 0stone at x 24, z 0stone at x 4, z 1stone at x 4, z 2redstone dust at x 4, z 3stone at x 10, z 1stone at x 10, z 2redstone dust at x 10, z 3stone at x 16, z 1stone at x 16, z 2redstone dust at x 16, z 3stone at x 22, z 1stone at x 22, z 2redstone dust at x 22, z 3
Layer 3 (3 up)
lever [face=floor, facing=north, powered=false] at x 0, z 0redstone dust at x 1, z 0redstone dust at x 2, z 0redstone dust at x 3, z 0redstone dust at x 4, z 0repeater [facing=west, delay=1] at x 5, z 0redstone dust at x 6, z 0redstone dust at x 7, z 0redstone dust at x 8, z 0redstone dust at x 9, z 0redstone dust at x 10, z 0repeater [facing=west, delay=1] at x 11, z 0redstone dust at x 12, z 0redstone dust at x 13, z 0redstone dust at x 14, z 0redstone dust at x 15, z 0redstone dust at x 16, z 0repeater [facing=west, delay=1] at x 17, z 0redstone dust at x 18, z 0redstone dust at x 19, z 0redstone dust at x 20, z 0redstone dust at x 21, z 0redstone dust at x 22, z 0repeater [facing=west, delay=1] at x 23, z 0redstone dust at x 24, z 0repeater [facing=north, delay=1] at x 4, z 1redstone dust at x 4, z 2repeater [facing=north, delay=1] at x 10, z 1redstone dust at x 10, z 2repeater [facing=north, delay=1] at x 16, z 1redstone dust at x 16, z 2repeater [facing=north, delay=1] at x 22, z 1redstone dust at x 22, z 2
redstone dustredstone torchrepeater or comparatorinputlampsolid blockarrows point where a device sends its output; north is up

How it works

Exactly one output identifies the two-bit input value. The raised rails carry independent inputs into visible torch AND terms; repeaters isolate the output OR rails. Allow 60 game ticks for this teaching layout to settle.

  1. Each output checks for a particular input combination using direct and inverted input bits.
  2. After settling, a valid input pattern selects its corresponding output.

Truth table

Settled outputs after the inputs stop changing. 1 is on, 0 is off. Every row is checked in the simulator in all four rotations.

Bit 0Bit 1value 0value 1value 2value 3
001000
100100
010010
110001

Inputs and outputs

  • InputBit 0 (x 0, y 0, z 0)
  • InputBit 1 (x 0, y 3, z 0)
  • Outputvalue 0 (x 4, y 0, z 16)
  • Outputvalue 1 (x 10, y 0, z 16)
  • Outputvalue 2 (x 16, y 0, z 16)
  • Outputvalue 3 (x 22, y 0, z 16)

Blocks you need

120 × redstone dust, 49 × stone, 24 × repeater, 8 × redstone torch (on a wall), 4 × redstone lamp, 2 × lever.

Build it in the game: 207 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 ~0 minecraft:lever[face=floor,facing=north,powered=false]
setblock ~1 ~0 ~0 minecraft:redstone_wire
setblock ~2 ~0 ~0 minecraft:redstone_wire
setblock ~3 ~0 ~0 minecraft:redstone_wire
setblock ~4 ~0 ~0 minecraft:redstone_wire
setblock ~5 ~0 ~0 minecraft:repeater[facing=west,delay=1]
setblock ~6 ~0 ~0 minecraft:redstone_wire
setblock ~7 ~0 ~0 minecraft:redstone_wire
setblock ~8 ~0 ~0 minecraft:redstone_wire
setblock ~9 ~0 ~0 minecraft:redstone_wire
setblock ~10 ~0 ~0 minecraft:redstone_wire
setblock ~11 ~0 ~0 minecraft:repeater[facing=west,delay=1]
setblock ~12 ~0 ~0 minecraft:redstone_wire
setblock ~13 ~0 ~0 minecraft:redstone_wire
setblock ~14 ~0 ~0 minecraft:redstone_wire
setblock ~15 ~0 ~0 minecraft:redstone_wire
setblock ~16 ~0 ~0 minecraft:redstone_wire
setblock ~17 ~0 ~0 minecraft:repeater[facing=west,delay=1]
setblock ~18 ~0 ~0 minecraft:redstone_wire
setblock ~19 ~0 ~0 minecraft:redstone_wire
setblock ~20 ~0 ~0 minecraft:redstone_wire
setblock ~21 ~0 ~0 minecraft:redstone_wire
setblock ~22 ~0 ~0 minecraft:redstone_wire
setblock ~23 ~0 ~0 minecraft:repeater[facing=west,delay=1]
setblock ~24 ~0 ~0 minecraft:redstone_wire
setblock ~0 ~2 ~0 minecraft:stone
setblock ~0 ~3 ~0 minecraft:lever[face=floor,facing=north,powered=false]
setblock ~1 ~2 ~0 minecraft:stone
setblock ~1 ~3 ~0 minecraft:redstone_wire
setblock ~2 ~2 ~0 minecraft:stone
setblock ~2 ~3 ~0 minecraft:redstone_wire
setblock ~3 ~2 ~0 minecraft:stone
setblock ~3 ~3 ~0 minecraft:redstone_wire
setblock ~4 ~2 ~0 minecraft:stone
setblock ~4 ~3 ~0 minecraft:redstone_wire
setblock ~5 ~2 ~0 minecraft:stone
setblock ~5 ~3 ~0 minecraft:repeater[facing=west,delay=1]
setblock ~6 ~2 ~0 minecraft:stone
setblock ~6 ~3 ~0 minecraft:redstone_wire
setblock ~7 ~2 ~0 minecraft:stone
setblock ~7 ~3 ~0 minecraft:redstone_wire
setblock ~8 ~2 ~0 minecraft:stone
setblock ~8 ~3 ~0 minecraft:redstone_wire
setblock ~9 ~2 ~0 minecraft:stone
setblock ~9 ~3 ~0 minecraft:redstone_wire
setblock ~10 ~2 ~0 minecraft:stone
setblock ~10 ~3 ~0 minecraft:redstone_wire
setblock ~11 ~2 ~0 minecraft:stone
setblock ~11 ~3 ~0 minecraft:repeater[facing=west,delay=1]
setblock ~12 ~2 ~0 minecraft:stone
setblock ~12 ~3 ~0 minecraft:redstone_wire
setblock ~13 ~2 ~0 minecraft:stone
setblock ~13 ~3 ~0 minecraft:redstone_wire
setblock ~14 ~2 ~0 minecraft:stone
setblock ~14 ~3 ~0 minecraft:redstone_wire
setblock ~15 ~2 ~0 minecraft:stone
setblock ~15 ~3 ~0 minecraft:redstone_wire
setblock ~16 ~2 ~0 minecraft:stone
setblock ~16 ~3 ~0 minecraft:redstone_wire
setblock ~17 ~2 ~0 minecraft:stone
setblock ~17 ~3 ~0 minecraft:repeater[facing=west,delay=1]
setblock ~18 ~2 ~0 minecraft:stone
setblock ~18 ~3 ~0 minecraft:redstone_wire
setblock ~19 ~2 ~0 minecraft:stone
setblock ~19 ~3 ~0 minecraft:redstone_wire
setblock ~20 ~2 ~0 minecraft:stone
setblock ~20 ~3 ~0 minecraft:redstone_wire
setblock ~21 ~2 ~0 minecraft:stone
setblock ~21 ~3 ~0 minecraft:redstone_wire
setblock ~22 ~2 ~0 minecraft:stone
setblock ~22 ~3 ~0 minecraft:redstone_wire
setblock ~23 ~2 ~0 minecraft:stone
setblock ~23 ~3 ~0 minecraft:repeater[facing=west,delay=1]
setblock ~24 ~2 ~0 minecraft:stone
setblock ~24 ~3 ~0 minecraft:redstone_wire
setblock ~2 ~0 ~1 minecraft:repeater[facing=north,delay=1]
setblock ~2 ~0 ~2 minecraft:redstone_wire
setblock ~2 ~0 ~3 minecraft:redstone_wire
setblock ~2 ~0 ~4 minecraft:redstone_wire
setblock ~2 ~0 ~5 minecraft:redstone_wire
setblock ~2 ~0 ~6 minecraft:redstone_wire
setblock ~2 ~0 ~7 minecraft:redstone_wire
setblock ~2 ~0 ~8 minecraft:redstone_wire
setblock ~2 ~0 ~9 minecraft:repeater[facing=north,delay=1]
setblock ~4 ~2 ~1 minecraft:stone
setblock ~4 ~3 ~1 minecraft:repeater[facing=north,delay=1]
setblock ~4 ~2 ~2 minecraft:stone
setblock ~4 ~3 ~2 minecraft:redstone_wire
setblock ~4 ~1 ~3 minecraft:stone
setblock ~4 ~2 ~3 minecraft:redstone_wire
setblock ~4 ~0 ~4 minecraft:stone
setblock ~4 ~1 ~4 minecraft:redstone_wire
setblock ~4 ~0 ~5 minecraft:redstone_wire
setblock ~4 ~0 ~6 minecraft:redstone_wire
setblock ~4 ~0 ~7 minecraft:redstone_wire
setblock ~4 ~0 ~8 minecraft:redstone_wire
setblock ~4 ~0 ~9 minecraft:repeater[facing=north,delay=1]
setblock ~2 ~0 ~10 minecraft:redstone_wire
setblock ~3 ~0 ~10 minecraft:redstone_wire
setblock ~4 ~0 ~10 minecraft:redstone_wire
setblock ~3 ~0 ~11 minecraft:redstone_wire
setblock ~3 ~0 ~12 minecraft:stone
setblock ~3 ~0 ~13 minecraft:redstone_wall_torch[facing=south]
setblock ~3 ~0 ~14 minecraft:repeater[facing=north,delay=1]
setblock ~3 ~0 ~15 minecraft:redstone_wire
setblock ~3 ~0 ~16 minecraft:redstone_wire
setblock ~4 ~0 ~16 minecraft:redstone_wire
setblock ~5 ~0 ~16 minecraft:redstone_lamp
setblock ~8 ~0 ~1 minecraft:repeater[facing=north,delay=1]
setblock ~8 ~0 ~2 minecraft:redstone_wire
setblock ~8 ~0 ~3 minecraft:redstone_wire
setblock ~8 ~0 ~4 minecraft:redstone_wire
setblock ~8 ~0 ~5 minecraft:redstone_wire
setblock ~8 ~0 ~6 minecraft:redstone_wire
setblock ~8 ~0 ~7 minecraft:redstone_wire
setblock ~8 ~0 ~8 minecraft:stone
setblock ~8 ~0 ~9 minecraft:redstone_wall_torch[facing=south]
setblock ~10 ~2 ~1 minecraft:stone
setblock ~10 ~3 ~1 minecraft:repeater[facing=north,delay=1]
setblock ~10 ~2 ~2 minecraft:stone
setblock ~10 ~3 ~2 minecraft:redstone_wire
setblock ~10 ~1 ~3 minecraft:stone
setblock ~10 ~2 ~3 minecraft:redstone_wire
setblock ~10 ~0 ~4 minecraft:stone
setblock ~10 ~1 ~4 minecraft:redstone_wire
setblock ~10 ~0 ~5 minecraft:redstone_wire
setblock ~10 ~0 ~6 minecraft:redstone_wire
setblock ~10 ~0 ~7 minecraft:redstone_wire
setblock ~10 ~0 ~8 minecraft:redstone_wire
setblock ~10 ~0 ~9 minecraft:repeater[facing=north,delay=1]
setblock ~8 ~0 ~10 minecraft:redstone_wire
setblock ~9 ~0 ~10 minecraft:redstone_wire
setblock ~10 ~0 ~10 minecraft:redstone_wire
setblock ~9 ~0 ~11 minecraft:redstone_wire
setblock ~9 ~0 ~12 minecraft:stone
setblock ~9 ~0 ~13 minecraft:redstone_wall_torch[facing=south]
setblock ~9 ~0 ~14 minecraft:repeater[facing=north,delay=1]
setblock ~9 ~0 ~15 minecraft:redstone_wire
setblock ~9 ~0 ~16 minecraft:redstone_wire
setblock ~10 ~0 ~16 minecraft:redstone_wire
setblock ~11 ~0 ~16 minecraft:redstone_lamp
setblock ~14 ~0 ~1 minecraft:repeater[facing=north,delay=1]
setblock ~14 ~0 ~2 minecraft:redstone_wire
setblock ~14 ~0 ~3 minecraft:redstone_wire
setblock ~14 ~0 ~4 minecraft:redstone_wire
setblock ~14 ~0 ~5 minecraft:redstone_wire
setblock ~14 ~0 ~6 minecraft:redstone_wire
setblock ~14 ~0 ~7 minecraft:redstone_wire
setblock ~14 ~0 ~8 minecraft:redstone_wire
setblock ~14 ~0 ~9 minecraft:repeater[facing=north,delay=1]
setblock ~16 ~2 ~1 minecraft:stone
setblock ~16 ~3 ~1 minecraft:repeater[facing=north,delay=1]
setblock ~16 ~2 ~2 minecraft:stone
setblock ~16 ~3 ~2 minecraft:redstone_wire
setblock ~16 ~1 ~3 minecraft:stone
setblock ~16 ~2 ~3 minecraft:redstone_wire
setblock ~16 ~0 ~4 minecraft:stone
setblock ~16 ~1 ~4 minecraft:redstone_wire
setblock ~16 ~0 ~5 minecraft:redstone_wire
setblock ~16 ~0 ~6 minecraft:redstone_wire
setblock ~16 ~0 ~7 minecraft:redstone_wire
setblock ~16 ~0 ~8 minecraft:stone
setblock ~16 ~0 ~9 minecraft:redstone_wall_torch[facing=south]
setblock ~14 ~0 ~10 minecraft:redstone_wire
setblock ~15 ~0 ~10 minecraft:redstone_wire
setblock ~16 ~0 ~10 minecraft:redstone_wire
setblock ~15 ~0 ~11 minecraft:redstone_wire
setblock ~15 ~0 ~12 minecraft:stone
setblock ~15 ~0 ~13 minecraft:redstone_wall_torch[facing=south]
setblock ~15 ~0 ~14 minecraft:repeater[facing=north,delay=1]
setblock ~15 ~0 ~15 minecraft:redstone_wire
setblock ~15 ~0 ~16 minecraft:redstone_wire
setblock ~16 ~0 ~16 minecraft:redstone_wire
setblock ~17 ~0 ~16 minecraft:redstone_lamp
setblock ~20 ~0 ~1 minecraft:repeater[facing=north,delay=1]
setblock ~20 ~0 ~2 minecraft:redstone_wire
setblock ~20 ~0 ~3 minecraft:redstone_wire
setblock ~20 ~0 ~4 minecraft:redstone_wire
setblock ~20 ~0 ~5 minecraft:redstone_wire
setblock ~20 ~0 ~6 minecraft:redstone_wire
setblock ~20 ~0 ~7 minecraft:redstone_wire
setblock ~20 ~0 ~8 minecraft:stone
setblock ~20 ~0 ~9 minecraft:redstone_wall_torch[facing=south]
setblock ~22 ~2 ~1 minecraft:stone
setblock ~22 ~3 ~1 minecraft:repeater[facing=north,delay=1]
setblock ~22 ~2 ~2 minecraft:stone
setblock ~22 ~3 ~2 minecraft:redstone_wire
setblock ~22 ~1 ~3 minecraft:stone
setblock ~22 ~2 ~3 minecraft:redstone_wire
setblock ~22 ~0 ~4 minecraft:stone
setblock ~22 ~1 ~4 minecraft:redstone_wire
setblock ~22 ~0 ~5 minecraft:redstone_wire
setblock ~22 ~0 ~6 minecraft:redstone_wire
setblock ~22 ~0 ~7 minecraft:redstone_wire
setblock ~22 ~0 ~8 minecraft:stone
setblock ~22 ~0 ~9 minecraft:redstone_wall_torch[facing=south]
setblock ~20 ~0 ~10 minecraft:redstone_wire
setblock ~21 ~0 ~10 minecraft:redstone_wire
setblock ~22 ~0 ~10 minecraft:redstone_wire
setblock ~21 ~0 ~11 minecraft:redstone_wire
setblock ~21 ~0 ~12 minecraft:stone
setblock ~21 ~0 ~13 minecraft:redstone_wall_torch[facing=south]
setblock ~21 ~0 ~14 minecraft:repeater[facing=north,delay=1]
setblock ~21 ~0 ~15 minecraft:redstone_wire
setblock ~21 ~0 ~16 minecraft:redstone_wire
setblock ~22 ~0 ~16 minecraft:redstone_wire
setblock ~23 ~0 ~16 minecraft:redstone_lamp