Let's Make Robots!

Best way to control 8 relays with a single arduino pin

I have the stepper motors for my drawing robot connected to the Adafruit motor shield via a bank of 4 double relays.

The reason for this is PURELY to protect the arduino from voltage created by me spinning the stepper motors while setting the thing up.

I have currently got the coils for all 4 (double switch) relays connected to the 5V line on the arduino.(in parallel, if that makes any difference)

As long as the board has power, the relays are closed, and the motors can operate. By unplugging the power from the arduino (powered via usb) the relays open, and i can spin the motors to my hearts content without putting power backwards into the motorshield (or arduino).

I want to add a little more control!

ie, have the arduino automagically, power up the relays when the motors are needed, but have them "normally" disconected the rest of the time, to save me from having to unplug the usb cable every time i want it to do anything!

Can i just move the 5v coil wire directly to a pin, which i set high, or low using the sketch, or should i build in a transistor?

If i should build in a transistor, would 1 do? or should i use one for each relay?

Ideally a hard wired LED indicator would be good (ie, one not affected by code). i could just drop this on in parrallel with the coils with a suitable resistor perhaps?)

a little basic electronics guidence would be greatly appreciated.

many thanks. Ol.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Are you using unipolar or bipolar steppers?

I ask because, unipolar steppers break out the ground. Given that, it should then be fairly easy to disconnect the ground with a single transitor/MOSFET as suggested. However, I could be completely, and, totally WRONG. :D

He mentions 8 wires, so that would indicate two bipolar steppers.  But if I am overlooking something please say so.

OK.  So you are trying to physically disconnect the motors to keep generated voltage out of the circuit.  Then, yes, disconnecting only one side of the motor will be sufficient.

Spot on. Great, thanks! Sorry for my awful spelling. Pesky windows phone will only give me a qwerty keyboard. Can't think why they won't allow third party input apps!

During the physical set up of the device, the motors can end up spinning enough to cause the shield power led to light up. Not cool. The addition of the normally open relays Is to stop this. I tried running all the coils through on transistor, but ir didn't work. I guess the transistor couldn't provide enough current. If I only isolate one side of each coil, it will still work I pressume? That would halve me coil current requirements...

it sounds like you want to remove power from the side of the relay coils that are always connected to the power?  Assuming that is what you want, you will definitely need a transistor or something to control the power.  An arduino pin is capable of supplying about 50 mA tops, and only rated for 20 or 25 (can't remember which).  You could use another relay.  Of course you need something to drive it with.  A mosfet would be most efficient, in which case you need a p channel logic level mosfet.  You did say you are controlling the relay coils with 5 volts, right?    If that is the case, a p channel logic level mosfet connected source to +5 volts, drain to the relay coils, and gate to an arduino pin, with a resistor (1K to 10k) also connected from source to gate, will allow the arduino to turn on power to the coils by going low.  When the pin is high or set as input (on powerup) the power would be disconnected.  The resistor pulls the gate high (turns off the mosfet) when the pin is set as input

If my assumptions/understanding or what you are doing are wrong, it will need to be revisited.


I have done similar long ago with a 7407, but not sure how much current you think you might need to hide the shield from.  Just a thought.


Sounds like you want a normally open relay, if I am reading it right now.



Not fussed about individual control. They can all be controlled by a single high/low.

I currently have 8 relays, one for each wire. I guess i have doubled up here, i only need one for each coil?

I have done this very thing with Shift register.  One like an 74HC595. It will be more like two pins ffrom uC though, but you will have 6 more output pins.