I'm putting a Raspberry pi zero on a model train. The train tracks supply 12V DC which I step down to 5v with a Pi Jack. However, because the power is being supplied via the tracks, I can't be certain of the polarity of the DC power.
How can I invert DC polarity if it's reversed from what I expect?