Go Down

Topic: 12v DC Electromagnetic lock control  (Read 2727 times) previous topic - next topic


Hi guys,

I'm new to the world of Arduino and require just a little bit of help in how to operate a 12v DC electromagnetic lock.
The lock i wish to use is as follows:

I need a little help with how to connect it to my Arduino and ultimately operate it. What other parts would i need to connect this up such as relays etc. I have come across posts suggesting transistors used with other model/higher voltage locks, but I have very little experience with them. That being said I am very willing to learn so any way forward to post and other information on dealing with such locks is greatly appreciated. The rest of the project in terms of RFID capture and validation is sound; its just the control system that is somewhat a grey area for me at the moment.

Thanks in advance, its much appreciate!


You have a couple options, but the simplest one would be to use a 5v relay (The signal voltage is 5v, the output has to be 12v and at least a 1A capacity). Amazon has them by the bucket load.

Then you simply hook the input of the relay to the arduino (Should be 3 pins Signal, Ground, And Power). And hook the other end up to your 12v power supply and lock.


Just a logic level MOSFET with 150 ohm gate resistor and 10k gate-source resistor.  Its a solenoid, so
you need a free-wheel diode across the terminals too.   Look up the standard relay driving circuit in
the Playground.

There's little point driving a relay to drive another coil, do it on one step! 

Remember _logic-level_ n-channel MOSFET, on-resistance 0.1 ohms or less is fine, 20V rated or more
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


Thank you both for your answers to my question. I thought about the relay idea but I could never find a definitive answer anywhere about whether relays only are used with AC current or whether they support both AC and DC devices, thank you Galiphat_1G for clearing that up for me.   

Mark T, this is the first I have ever heard of a MOSFET but that being said and a little research has proved quite enlightening. I will admit it took a while to decipher your statements but I seem to understand the concept now.

I just have 2 questions regarding the use of MOSFETS. A tutorial i came across : http://bildr.org/2012/03/rfp30n06le-arduino/

Uses a diode between the positive and negative inputs to the motor/solenoid, from the diagram it makes sense as to why it is there but I could not for the life of me so far (Being a newb at circuits so far) figure out where exactly to connect the diode (close to the solenoid or on the PCB). If anyone can send me a photo/link of a physically connected diode like the diagrams depicts it would help me greatly understand how all connects together. I do have a slight idea but don't want to run the risk of stuffing up what I'm building before i have even seen it work.

Forgive me if this is blatantly obvious but my logic behind all this is most probably different, but the MOSFET has 3 pins, the gate, source and drain...in the diagram of the tutorial why is the drain connected to the (-) of the solenoid/Motor and not the source? My (flawed) logic tells me it would make more sense that the (-) would be connected to the source of the MOSFET as this is where current is coming from and the drain would go to the ground as you are "draining" the current out of the circuit. If anyone can help me make more sense of the pins of the MOSFET I would really appreciate it.

Thanks so far guys :)


Feb 09, 2016, 02:58 pm Last Edit: Feb 09, 2016, 03:08 pm by JimboZA
The photo here shows how the diode goes, and the circuit diagram is basically correct although it's not a mosfet (edit: and does not show the gate/source (base/emitter) resistor). The diode is "backwards" intentionally, ie the diode cathode is on the positive side of the supply.

Looks to me like an IRL520L from MicroRobotics will do the trick, but maybe let the other guys confirm it's ok.

I have wondered about the mosfet pin naming too; perhaps it's to do with the fact that the electrons actually go opposite to the convention, so they go in the source and out the drain? That's basically a guess though

Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)
Dr Perry Cox: "Help me to help you, help me to help you...."
Your answer may already be here: https://forum.arduino.cc/index.php?topic=384198.0


Current is carried by charge carriers, which in a semiconductor might be electrons(-ve) or holes(+ve).

In an n-channel MOSFET the charge carriers are electrons and travel from source to drain.
In a p-channel MOSFET the charge carriers are holes and travel from source to drain.

The names are all to do with the movement of charge carriers, same goes for emitter and collector
in BJT's
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


Thanks guys for the replies, its making more and more sense but i think this circuit diagram
is incorrect then.

In Mark T's (thanks for the explanation) quote below:

In an n-channel MOSFET the charge carriers are electrons and travel from source to drain.
In a p-channel MOSFET the charge carriers are holes and travel from source to drain.

He says the electrons (n-channel MOSFET) move from source to drain. but the diagram depicts the opposite (In my logic) as the solenoid is receiving a positive current then the negative of the solenoid is connected to the drain and the source is connected to the ground... My understanding is current moves + to - in this case we have a + coming from the negative terminal of the solenoid into the drain to the drain of the MOSFET and the Source is sending this to the ground. If I understand what Mark T said, the electrons move source to drain which in my understanding means + into source and - out of drain. Am i correct in stating that? Sorry if this is beginning to get frustrating but I cant seems to grasp the logic of the naming of the pins and the way the current flow through them as the diagrams i have seen contradict the theory i have read. I have not been able to source a concise write up on how the pins function and where current flows and in what direction. Unless this diagram i have been referencing all along has been incorrect.

Thanks for your patience guys.


The diagram is correct.  Electrons flow from ground, into the source, out of the drain, through the load
to the +ve supply.  Electrons are negatively charged and are attracted to the +ve.

Normally in electronics we only think in terms of conventional current (notionally +ve charges flowing),
you must not confuse electron flow with conventional current, they go different directions!

The diagram is bad however, in that it doesn't have a 150 ohm current limiting resistor between
gate and Arduino pin!
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]


Ah ok now it makes sense, thank you so much! This was really bugging me. So the current from the solenoid will still make it to the ground wire following the + to - flow its just electrons that confuse the naming of the MOSFET. MOSFET just acting like a switch Bridging the Drain and Source via the Gate. Awesome, thank you guys again. Its much appreciated.


Small MOSFETs as inside logic chips and processors are completely symmetrical - source and drain are
interchangable.  Current flows horizontally.

Power MOSFETs are completely asymmetric and even have a built-in diode due to the structure and
the vertical current flow design - the back of the die is the drain and the wide path for current allows
the low resistances (a few milliohms rather than a few kiloohms).
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up