I am new to arduino and need some help. I just baught light bars for my jeep and wiring harnesses with them, the harnesses come with buttons and I wanted to replace the button and have them controlled on my phone. The harnesses come with a relay and a fuse and a button all 12v, How would i go about using my raspberry pi or udoo x86(which has built in adruino) to basically replace the rocker switch so i can then turn things on and off without needing to have actual switches.

  • a simple MCU can do it. no need to have a computer for this. use Arduino Nano or Mini – Juraj Jun 12 at 8:12
  • Google: "Arduino relay" and look at the pretty pictures. – Majenko Jun 12 at 9:36
  • 1
    Or, if you don't want to mess with the harnesses electronic, you can bridge the buttons using a MOSFET, which can be directly controlled by Arduino or the Pi. – chrisl Jun 12 at 9:49

To drive a relay you'll need a transistor (a MOSFET is a good choice) and you'll need a diode across the relay coils to protect the transistor from the reverse current pulse when you remove power from the relay coils.

As Majenko says, if you Google "Arduino relay" you'll find lots of articles covering the topic. (And if you use a digital output line from your PI the exact same circuit will work.)

This MOSFET is a good option for switching high current loads with a 5V logic signal:


The diode will need to be a power diode that can handle your voltage/current needs. You'll need to figure out how much current your light bar uses, and then I'd suggest a diode that can handle twice that much current (at 12V) for a margin of safety.

  • Re “handle twice that much current (at 12V)”: Not at 12 V. It should handle the current when forward biased, and the voltage when reverse biased. – Edgar Bonet Jun 12 at 12:02
  • why not MOSFET only – Juraj Jun 12 at 15:29
  • An inductive coil like a relay coil dumps a large surge of reverse current when you remove power from it. (sometimes called "flyback current".) That is enough to destroy a transistor, so you need a diode to protect the transistor. – Duncan C Jun 12 at 16:32
  • how do i see how much current the lights bar uses, can i just use the volts and amps that the relay says on it? also things say i need a resistor, how do i choose that also. – JamminGinger Jun 12 at 20:11
  • henrysbench.capnfatz.com/henrys-bench/arduino-output-devices/… this is the circuit i think i will use with the mosfet, does each mosfet use a different ground or all the same – JamminGinger Jun 12 at 20:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.