built these optocoupled circuits to drive a 12v light from arduino uno

Hello all! I am relatively new to electronics and not too new to coding - so I would like some feedback on my schematic that I’ve generated from Fritzing.

In short what I am looking to do is drive a power FET with an Arduino digital signal. I have a basket of 4N35 optocouplers, and IRF540 MOSFET - N channel MOSFETS. I know that N-channel mosfets source current from ground, and that’s how they turn on and off by switching off and on the N-channel. I hope my terminology is correct! So I put together - based on other projects and products I’ve seen - a schematic that I’m trying to turn into a PCB to control 12v lighting. The IRF540 with heatsink can handle some pretty high current loads!!!

So what I have here are two circuits intersecting at the 4N35. This is a 5v Arduino circuit for the digital signals, and a 12v power circuit to drive the load (s). Both go back to their respective battery grounds because of the opto-isolation. That said - anything I could do to prevent say a voltage spike on the 12v side or overcurrent would be helpful. Also if I did anything wrong - or something is represented incorrectly, it would be greatly appreciated if the experts out there could provide some feedback. This is my first shot at a schematic - so bear with me!!!


just a quick comment.

Its not the best use of an NPN transistor I've seen. There is probably a better way.

pwillard: just a quick comment.

Its not the best use of an NPN transistor I've seen. There is probably a better way.

There aren't any NPN BJTs in those circuits, moncureww is using a N channel MOSFET.

to prevent say a voltage spike on the 12v side

A reversely connected e-c junctions of a npn (base remains open) will do. Those devices have about 10 - 15v or breakdown voltage and are ideal for gate protection.

And they are incredibly fast and cheap too.

Wow! I didn't know frtizing made readable schematics - this is the very first clear one I've seen!

I don't see the compelling need here for the isolation. I think you will have better results if you use the NPN as an open collector device to pull the MOSFET N-channel gate low when you want to turn off the MOSFET off, and use a pullup resistor to +12 to turn it on and connect the light bulb '-' to the battery -.

Crossroads - sorry to be such a "newbie" but if you could give me a laymans' idea of what you are saying (i.e. standard resistor values, connect x to y, etc.) certainly I'll understand. I'm pretty quick on the uptake and really need to see cookbook/textbook examples once to get the general principle. But as for the isolation - I just want to use a standard configuration across a board that will have multiples of this same circuit for switching, in some cases, devices that could have inductive loads and such. I am just overly cautious!

About the Fritzing schematic creation - let me say one thing.

Three different views in Fritzing - breadboard, schematic, and PCB. Once you breadboard something, on the schematic page (and the PCB page) Fritzing tosses everything into a giant ratsnest of wires / traces and then you gotta go about sorting it all out and making it "pretty."

Like most software it's just a tool and a lot of folks just double-click connections and - wham - you have ground in the upper right corner, an LED array diagonal across the screen, and somewhere half off the screen you have source voltage. It's about laying things out nice!

I don't like to create schematics unless they're clear - and the whole fritzing thing has really enabled me to start thinking in terms of hardware better than I ever have before. Without having to use my clumbsy fingers I can build, rip out (no static issues!) and rebuild things until I get them right. My idea is to train on fritzing and advance to eagle so to speak.

DHenry - thanks for the advice! Greatly appreciated. I'll keep that in mind. I have so much stuff sitting around here - I bought a monster package of IC's and all sorts of stuff from an online retailer (a rather nice assortment for a good price from a guy working out of Vermont and Asia). I just want to put this veritable potpourri of MOSFETs and IC's to good use while learning what I have!

Yeah, I'll whip something up when I get home - nothing here to create with except powerpoint, very tedious. It won't be a big change, just moving the emitter to gnd, the collector to the gate, and a pullup from the gate to +12 in place of the 100 ohm.

Arduino output 0 = output load on, 1 = off

There's mny ways to offer protection other than total isolation, like zeners for example that would probably offer adequeate protection

The problem there is it isn’t total isolation… the grounds would need to be connected… what he is doing is “Sending a Message” for control thru the opto-isolator, not controlling it directly and having to deal with as he said many different devices including inductive ones and his idea is best as the only connection to the Arduino is to the cathodes and anodes of the Opto’s. It isn’t necessary to connect to the controlled devices grounds. Better If he will need to control a bunch of devices would be a shift register then you could control 8 per shift register and the shift registers are chainable with 3 wires from the Arduino too.


There is no ground connection between the teft battery and the right battery edison- nothing between the circuits but light from the LED.