How would you make a counting machine with wiring?

Basically there are 1 button and 3 toggles

Button hasn’t been pressed - toggles 0,0,0

Button pressed once - toggles 1,0,0

Twice - toggles 0,1,0

Three times - 0,0,1

Four times - 0,0,0

If I needed something like that when programming, I could do

void onButtonPressed(){
If (!toggle1 and !toggle2 and !toggle3){
toggle1 = true;
}
else if(toggle1){
toggle1 = false;
toggle2 = true;
}
else if(toggle 2){
toggle2 = false;
toggle3 = true;
}
else if(toggle3){
toggle1 = false;
toggle2 = false;
toggle3 = false;
}
}

Trying to turn that into a circuit doesn’t work because I have no idea how to make an else if using gates.

The circuit needs to stop checking as soon as one of the conditions is true, but also be able to check everything again after the button is pressed again.

If you use regular ifs instead, it just goes through all of them instantly and doesn’t actually count.

I could probably make the circuit stop, but that would only work once, meaning if the button is pressed again, the circuit won’t continue counting.

Never mind, I’m dumb.

It doesn’t go through all of them, since the conditions are different

Edit: I’m dumb², it does go through all of them. Forget what I said.

Edit2: That’s basically the only problem. I don’t know how to make an else if with gates so it doesn’t just quickly go through all of them.

I have one solution to this problem that works, but I really don’t want to use because I don’t think that’s what the root of the problem is.

can u show me in game

This seems very close to a “Swap Switch” Ondrashek asked for here.
Only difference being is, that I use a lever there to allow faster changes in input. Of course, if you still want to use a button, just use a button and a toggle gate to substitute for the lever.

Since Ondrashek didn’t even have the decency to reply to that, I hope at least you can make use of it.

2 Likes

It looks nice, but it is hard to continue.

What I was thinking of, looks more like a “switch counter” (you can look it up on google).

But I don’t understand how a switch counter works.

I mean, I understand the scheme, but I think it would just turn every toggle on from the start, so it doesn’t make sense to me.

The solution I have right now, is basically having 2 toggles for each toggle that I want to use for counting.

The first toggle activates when the button is on, the second activates when the button is off, and if the button is on again, and all the toggles are on, the next pair of toggles activates.


If you meant it like the one on the right side, yes, it would all turn on from the start. The right one basically counts “backwards” or down in binary.
To make it count up, simply add NOT Gates like I did on the left.

I suggest you stick with binary and don’t bother with the hell that (imo) is converting that to decimal with a contraption.

2 Likes

Turns out there are different types of flip-flops (that’s what they call toggles in computer science).

I’m checking the switch counter scheme on another software, not pixel worlds, to have acces to these flip-flops. I might be onto something.

I needed the counter because of a bit (no pun intended) different reason.

Edit: I got it. Flip-flops are different from toggles in a way that most flip-flops only switch to on if there are 2 signals that came at the same time.

This circuit works. It turns toggles on, left to right, with each button press (on the left).

(The switch counter is irrelevant, btw, it just works like delay.)

Edit2: I will look into that more, later.
Edit3: I was wrong, the circuit on the first edit shouldn’t work, it’s just a bug of the software probably.

1 Like