I have an electromagnet that I wish to use to pull a neodyne magnet closer.

I'm thinking of having the electromagnet sensing when the magnet is close, but when the magnet is running I'm pushing 12 volts through it and I don't want to fry my Arduino. How can I do the wiring to achieve this?

I only have to be able to use the magnet as a sensor while it's turned off.

  • 1
    You could drive the electromagnet with 12 V and at the same time read back the current through a small shunt resistor. Sep 16, 2016 at 12:54
  • Just add a resistor an a clamping diode to the analog pin. That way overcoat age can't damage the Arduino pin.
    – Gerben
    Sep 16, 2016 at 15:55

1 Answer 1


You can use a hall sensor from an old computer fan.

If the magnet is not moving you are not going to be able to sense it with the coil of your electromagnet. You can also decouple de input of your arduino with a cap in series with the coil, but again if the magnet is not fast enough you will have to use a bigger cap.

You can also make a voltage divider between your coil and sense from there. When the 12V are applied just add some code to offset the input signal.

Your Answer

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

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