Wednesday, August 24, 2011

Switches? I don't need no stinkin' switches! Or do I?

Question

I have an iron door on the first floor (to the outside) of my tower. I tried to put a switch on both sides of the door so it can be opened from the inside and the outside. My problem is that because the switch has an "On" and "Off" if I open the door from the outside I need to turn "On" the switch on the inside, go back outside and turn "Off" that switch, just to run back inside and turn "Off" the inside switch to finally get the door to close. This is a giant pain in the rear when I have mobs chasing me to the door.

Is there any way to use switches to open and close the door no matter their position? Or would it be easier to use a button and just run through the door and have it close behind me automatically?

Answer

Buttons would certainly solve that problem, but you could also use an XOR gate between two switches which is how two-way switches work in the real world.

XOR Truth Table

  A  |  B  |   C 
-----+-----+--------
  0  |  0  |   0
  0  |  1  |   1
  1  |  0  |   1
  1  |  1  |   0

As you can see, if either A or B changes (either of your switches), C (the output--your door) will as well.

There are a bunch of these on the YouTubes, but here is one that operates a set of double-doors:

No comments:

Post a Comment