Using single 12v DC power source for project

When you interrupt the current to an inductor, which is what a maglock is, the inductor tries to maintain the current. If the terminals of the inductor are open circuit the inductor has to produce a high voltage to have any chance of maintaining the current, possibly several hundred or 1000V. You don't want 1000V near a microcontroller.
See:

For what to do about it.

2 Likes