DC motor don't come back in same position

The Arduino should have no problem dealing with 340 pulses per second - that is one every 2900 microseconds.

You have not said how many pulses there are per revolution - or maybe all that is relevant is how many pulses are needed to open or close the gate.

...R