Geeze... a problem summarised in one short paragraph. The last one that landed on my desk was 27 pages deep...

So, you have a 1 Button Remote, to control a 2 Button application.

Press the Button momentarilly and the Gate goes UP. This means that for safety in an emergency it goes UP if you hit it.

If the Gate is already in motion (in any direction) when it receives a Button press, it STOPS.

Press the Button and HOLD it for at least 3 Seconds before releasing and the Gate goes DOWN.

If it's a Prison Gate, just reverse the priority...

30 seconds, done and dusted... and the next problem...