Powering a small "electromagnet" directly from an Uno?

I would like to hold a ball bearing in place with an electromagnet, and then set it free and let it roll down a tray.

So far I have a nice solenoid with an iron core from a scrapped 24V relay.

When I supply it with 5V, it is plenty strong enough for what I need.

Looking on the basic values, I think I could power it directly from the Uno.

  • measured resistance: 333 Ohm
  • measured current when powered from a 4.5V battery: 12 mA

I will of course put a reverse biassed diode across the solenoid to deal with the voltage spike when it is switched off.

I feel safe, but I've learned from experience, to be worried when that happens.
:grin:

Am I overlooking something?

I like to always put an transistor to control this type of devices. Something like this:

Yes you can drive that solenoid directly from an Arduino pin.

I agree with dc42, you can use it directly.
But please use two protection diodes ! From GND to output pin, and from output pin to 5V. The small 1N4148 is fast and can handle current peaks.

If its 333 ohm its only going to use 15 mA but only thing I don't like is the wire in these things is enamel paint and a used one could easily break down and short. Why not pop a npn 12 cents then to chance a uC thats 4 dollars.

Thanks to all of you!

I have a box of 2n2222 transistor, and if I was going to use it in a more permanent setup, I'd probably use one of those.
For some quick experiments, I'm willing to take the risk and keep everything as simple as possible.