# Cut redstone circuit when a signal is sent

I have a simple thing to do : whenever a minecart is on a `Detector rail` it triggers a piston to block it, and when another signal is thrown by any source, the redstone circuit is cut and the piston turns off and liberates the minecart

Here is an image of what I started :

I'm lost for where I should go to cut off the circuit

Thanks you very much!

## 3 Answers

I created a solution, using the detector rail to put out a redstone torch which then allows a second redstone torch to power some dust which powers the smooth stone which powers a sticky piston attached to the rail blocking it. Then, we can just power the second torch to allow it to go again. Attached below are some screenshots.

If you have two inputs and one output, it's often useful to make a logic table:

``````┌───┬───┬───┐
│IN1│IN2│OUT│
├───┼───┼───┤
│ 0 │ 0 │ 0 │
│ 0 │ 1 │ ? │
│ 1 │ 0 │ 1 │
│ 1 │ 1 │ 0 │
└───┴───┴───┘
``````

`IN1` is the minecart on the detector rail, `IN2` is your release signal, `OUT` is the piston. The output for the case of no minecart on the detector rail and the release signal being pressed doesn't matter, so I put a question mark there.

The logic table tells us that you need either an `XOR` gate or an `AND` gate with the second input inverted. An `AND` gate with one input inverted can be built cheaper and more compact, so I'll take that as an example.

Since the most common `AND` gate in Minecraft inverts both inputs, uses redstone dust to check if either is on (an `OR` gate) and then inverts the signal again, you basically just need to build the regular `AND` gate with one redstone torch less:

The top left lever is your detector rail input, the bottom middle one is your "release" signal. The lamp only turns on (the piston extends) if there is an input from the top right (minecart on track) and no bottom middle input (release signal). This should also be a more "sane" behaviour than the `XOR` gate, which would have extended the piston on the release signal if there was no minecart on the track.

In your situation probably the easiest option will be to use a comparator in subtraction mode.

The signal will pass through the comparator unaffected, with only minimal delay, if there's no signal from the side. In presence of the side signal, its strength (thanks to use of repeater, the maximum, 15) is subtracted, leaving 0 on output. Depending on geometry (distance of the comparator from the rail, distance of the 'departure' signal source) you may be able to skip the repeater.