I am creating an escape room for my daughters birthday which is a lot of fun. I'm completely new to Arduinos and electronics in general so expect the newbie question.
I have created a puzzle involving four potentiometers and a maglock door release. It works great, however I'd like to power the entire thing from a single 12v 2A power source. Currently I power the Maglock (12v 300mAh) in a separate circuit to the Arduino as it has a higher current demand. The arduino Nano is powered by a USB C cable.
I know the Nano can take an unregularted power supply on the VIN pin so it should theoretically be ok to just connect this up to the same DC power supply as the Maglock, however, I'm not sure if this is safe? or if I should be putting other components in the circuit for protection, e.g. Diodes or Capacitors, I see this done from others online but unsure of the logic around the use, so asking the community for some advice! Ideally I don't want to try it and risk frying my Nano
After reducing 12V to 5V, the puny voltage regulator on the Nano can only source about 150mA without overheating and shutting down or failing, The relay coil draws 72mA, you need a "buck" converter that can drop the 12V to 5V and supply at least 800mA @ 5V, connected to the Nano's 5V pin.
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:
Thank you @PerryBebbington , I'm glad I asked the question before trying it out! I'll read your post tonight and look to integrate the diode into my circuit also.
Nano is not power hungry, so if you want simpler solution, you could use 1W zener diode in series with Arduino Vin, to get the desirable voltage drop. For example if you use 5V6 zener you will get 12 - 5.6 = 6.4V on the Vin pin.
Just be careful, if you reverse polarity of the zener, you will get only 0.6V voltage drop, instead of 5.6V.