Reversing output polarity


I need to switch a 9v power supply from my uno. I have looked at the simple transistor circuit and I am happy with that. However, I also need the option of switching the polarity. There is lots of information about how to reverse polarity of motors using H-bridge etc... but I cant find anything specifically for what I want to do.

Imagine a control panel that has a 3 position switch and a pot. The 3 position switch has forward/off/reverse, the pot controls the output voltage from 0v-9v.

I'm happy with the pot and transistor in a single direction, but how could I reverse the output polarity?

Thank you in advance. I have done lots of searching but all I can find is info on reversing motors. I think (or hope), that my application should be more simple.


A relay (either a DPDT relay or two SPDT relays) will work. Don’t forget the flyback diode on the relay coil.
SPDT circuit:

DPDT relay:


It is an output polarity that I'd like to reverse. A train track has a "common" and 9v rail to run the train forwards. To reverse the train, you reverse the polarity.

I want to be able to do that with a 3 position switch like the "off-the-shelf" train controllers. forward/off/reverse

Hi JR,

Thank you for that. How does this tie in with Arduino? Where are the uno pins connected and what are they doing?

You don't need an Arduino or relays between a three position switch and a motor.
Unless you want to add some more intelligence.

Just use a DPDT switch with center-off position.

How does this tie in with Arduino?

An Arduino output pin, probably using a transistor, would activate the relay(s) that switch the power supply polarity.

Google “arduino relay” for lots of advice.

Thanks JR, I’ll have a look at that. Just thinking about the transistor at the output end, normally its recommended to out a diode across the output to prevent back feed. How does this work in my situation? Or is it not an issue as technically the +- are not coming from arduino, just the power source? If only the triggers for the output supply transistor and the “switch polarity” transistor are connected to arduino then how will the pot work in both directions?

Thanks for the help so far, I originally thought it would be simple, but like most things it doesn’t seem that way.

How much current does you train(s) require?

Max 1amp

Will a physical switch work for you or are you trying to do this electronically?

I have played around with reversing circuits for N, Z and T trains and I used a motor controller to do the reversing.

This avoids the Click-Click of relays.

Hi. Ideally I’d like to do it electronically. My plan is to have sensors and gates/shunting to be done automatically.

Me too.

This is my buddy's layout in N.

I think when that video was taken, he only had 4 point to point circuits. I think he is up to 6 now.
And I am trying to make new ones for him. The hitch for me has been powering it from the transformer.
I can easily rectify the Accessory to power the arduino.
I can easily power the motor driver from the DC track power.
But (i suspect) that these 2 circuits have different grounds. Because when I make the ground common, it pops the over-temp protection in the transformer in about 10 seconds.

For my Z and T work, everything will be running on batteries so no such problems.

What scale are you working in?

I’m working in N so could potentially use a battery but I like the idea of just switching on and off and not worrying about batteries.

I started with the cheap auto reversing circuit here.

Warning this is my NON working circuit!!!

This is wht I based my work on. The relay (clicky clicky) isolates the rest of the circuit from the track power, so the 2 grounds are not connected.

With either circuit, this is the track layout with diodes to stop the train until the polarity is reversed.

Thank you for the info. And nice layout by the way. Lots of trains running! I’ll have a read over your links soon.

Lots of trains running!

He does like a lot of action.
That is a 3'x4' layout with 11 moving trains (IIRC)
I can appreciate the art even if it is not the choice I would make.
And he provides the beer if I do his soldering. Win-Win!