Minecraft – How to make redstone lamps light up one by one

minecraft-java-editionminecraft-redstone

I want to make this : I have one button and three redstone lamps (lamp 1, 2 and 3). If I press the button once, the lamp 1 will turn on and will stay turned on. Then if I press the button a second time, this is the 2nd lamp that will turn on and stay turned on (and not the 1st nor the 3rd, the first will turn off), if I press the button a third time, the third lamp will turn on, and finally, if I press the button a fourth time, the first lamp will light up, …

Each time I press the button, the lamp that is turned on will turn off and the next lamp will turn on (except for the last lamp, in which case, the first lamp will turn on)

I want to make this, without using any piston and easily generalizable to any number of lamps.

Thanks.

Best Answer

One nice thing about redstone is that you can often just combine two existing circuits to get a new circuit that does something else. In this case I combined Xisuma's item frame selector circuit with my "flip-flop-flap" to create this:

In the dropper on the left there are currently 8 unstackable items. You can also use less, to only use the last few outputs. When you press the button, all lamps turn off for the duration of the button (you could turn on another one in that time if you wanted to, or shorten the pulse before inputting it into the circuit) and then the middle lamp in the bottom lights up and stays on. Another button press, all lamps turn off and then the bottom right one turns on. Then top right, going to the left. When you press the button while the last lamp is on, all lamps turn off for a bit longer and then the bottom left one turns on again.

Normally I also list materials, size and so on, but luckily Xisuma already did that for his part and I already did it for my part in the linked answer, so you can just add the resources and size for both.

Of course you could also just use an item frame instead of a button, then the entire left half isn't necessary and the circuit reacts with only 1 tick delay and without an off phase, but you asked about a button. If it is an option, just build Xisuma's circuit. But this doesn't generalise, it only works with the 8 rotations of an item frame.