# using solenoid magnetic field to press a button

I'm looking for a simple way to make Arduino press a spray button. I don't care which button to use, it can be either this type:

or the following:

I know there are ways to solve this problem using a servo, but I'm trying to think about a simpler way that won't demand an engine (or will demand one but will be simple to implement).

I thought of the following - Perhaps I could place a weight on the cap of the spray, inside a solenoid and connect the solenoid with electric wires to the Arduino. I could pass current in the solenoid and create a magnetic field which will press the weight which in return will press the spray cap. The Arduino will control when to pass the current and when to halt. A sketch of the system is shown in the drawing below:

I'm not sure if it's possible (If I can get enough force to press the cap without a huge solenoid or extremely high currents which I can't produce at home) so I'd like to hear your opinion.

I thought it will resemble the principles of operation of a magnetic train such as this one.

The math:

I can use the following formula to calculate the magnetic field within the solenoid: $$B = \mu nl$$ where $$n = N/L$$ It probably won't be the exact magnitude of the magnetic field since the formula is ideal, but I guess that if I take a solenoid which produces bigger magnetic field (in magnitude) it will compensate for the inaccuracy of my ideal state calculations.

now I can use this formula to calculate the force which is applied on the weight when it is pressed and reaches a steady state: $$F_{gravity} + F_{solenoid}$$ when $$F_{gravity} = mg$$ and $$F_{solenoid} = IBl$$ where I is the current which flows through the solenoid and I determine it, B is the mangnetic field inside the solenoid which I already clculated (depends on the type of solenoid I will choose to work with) and l is the solenoids length. The forces are shown in the force diagram below:

I can calculate the desired force for the button pressing using something like this solution.

From the former I can calculate choose the solenoid type and the weight which is needed.

My questions are:

1. What do you think about the solution? Will it be easy to execute? Is it an overkill? what other idea do you have?

2. I'm not sure which solenoid to choose - when I looked at some solenoids for sale, they never mention the n factor (how many turns per unit length) or the permeability factor mu.

3. I'm not sure how to calculate the drag of the air which occurs at the beginning of the movement and may diminish the net force I get which the weight "feels". Perhaps it can be neglected since it'll operate for very short period of time (when the button will be pressed it'll stay like this in the exact location without any velocity, so the drag will be 0 by this equation)?

Thank you.

• Look for solenoids that have a spec that tells you the force they can exert. Then ask yourself what force actually needs to be exerted. You also need to factor in that the distance to press the button shouldn't diminish the force as it travels so look for a solenoid that matches or exceeds your requirements. No need to do all the magnetic stuff. Find a solenoid that works first then, if you want to build your own (why?) copy the one that works. Forget about drag. Oct 3, 2020 at 8:33

Most commercial aerosol dispensers use a motorised cam mechanism. This gives adequate mechanical power at very low electrical power.

Figure 1. This particular mechanism runs forward to drive the segmented gear down on a custom nozzle. It must then run in reverse to go home. Note the easy mounting arrangement: pull the standard nozzle off, fit the custom nozzle and push into the bracket. Image source: EC Plaza.

These are commonly employed in air freshener dispensers and will fire a shot at pre-determined intervals.

If use of a solenoid is specified then I would be considering a pilot-operated type. This uses the fluid pressure to do most of the work and the solenoid just has to do a very small motion on a small valve.

Figure 2. A pilot-opererated solenoid valve. Image source: ATO.

The linked article has a decent explanation of the principle of operation. In your case you would need to remove the nozzle and somehow attach a tube to the canister and hold the can's internal valve open to supply constant pressure to the pilot valve.

• Hint for hobbyists : that motorized cam mechanism looks a LOT like the insides of an RC model servo.
– user16324
Oct 3, 2020 at 11:37

A solenoid is a poor choice of engine, by which I mean something that has to do work on a button, or weight or spring to press a button.

Solenoids tend to have very low force at the start of their stroke. The longer the stroke, the lower the force, other things being equal.

A servo, basically a motor and gearbox packaged to be easy to use, is the best way to get some energy into a button-pressing mechanism.

Superficially, a motor and a solenoid use the same types of electromagnetic forces to operate. However, a motor has small air-gaps, and achieves a large movement by repeating the same, small, efficient movement over and over again. In contrast, a solenoid uses a large air-gap to get a large movement, and this makes it extremely inefficient.

When you go shopping for solenoids, the specification to look for is force at start of stroke, and length of stroke. You will be able to buy a large enough solenoid to be able to press your spray button, but it will need orders of magnitude more power input than a suitably geared motor, or packaged servo.