I'm just starting up with electronics and looking to control an electromagnet with the Arduino. I'm wondering what hardware setup will make the most sense to use to turn the electromagnet on and off at around 10 times per second. I plan to make the magnets using coiled wire. From what I have read, I need to get a transistor to switch power on and off.

In summary:

  • Should I use a transistor? If so, what transistor works well with Arduino for this application?

  • How do I supply power to the electromagnet? A schematic or explanation would be super helpful.

Thanks in advance!

  • 1
    \$\begingroup\$ You need to design the electromagnet first. The question cannot be answered and should be closed. \$\endgroup\$ Apr 29, 2012 at 21:37
  • 2
    \$\begingroup\$ @LeonHeller - Nonsense, there's plenty of answer that can be given here. \$\endgroup\$ Apr 30, 2012 at 11:12

2 Answers 2


First you'll need to find out / calculate / measure how much current the solenoid requires, and what voltage it requires. If the voltage is less than 50v (quite likely) and the current is less than 500mA, then you can drive it with a single outputof the good old ULN2803.

ULN2803 and solenoids

Here it is driving a bunch of solenoids. You can do up to 8. The best thing is that it already includes the flyback diode that you'll always need when you're switching inductive loads like this.

If you need more current, then you can use several outputs in parallel, up to a maximum of 2.5A.


Although I have never controlled an electromagnet from a microcontroller before - I have controlled high voltage loads, so the same principle applies. You can use discrete componets such as transistor pairs or you can use something called an HBRIDGE to drive the high voltage/current application.

Here is a tutorial on controlling high current loads with a transistor and an Arduino. Here is a similar tutorial that powers a motor with an H-Bridge instead. To use these tutorials simply replace the motor with your electromagnet. It shows how to use external power sources and everything.

This is more of a conceptual answer so it's application will vary slightly with your configuration. For the most part however this should get you on the right track.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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