Solenoids and Linear Actuators for Makers: Push, Pull, Latching, and Driving Them Safely
This site's relay guide covers switching AC and DC loads safely, and it mentions solenoids in passing as one of the inductive loads a relay might drive — but solenoids and linear actuators are worth their own guide because they're not just another switched load, they're mechanical devices with their own selection criteria, driving requirements, and failure modes. A solenoid lock on an escape-room prop, a pinball-style kicker, a pellet feeder, or a linear actuator raising a camera slider are all built around the same basic electromagnetic principle but behave very differently depending on type, duty cycle, and how you drive them.
How a Solenoid Actually Works
A solenoid is a coil of wire wound around a movable ferromagnetic plunger. Energize the coil and the resulting magnetic field pulls the plunger toward the center of the coil, converting electrical current into mechanical linear motion. That's the entire mechanism — no gears, no feedback, no fine control over speed or position. A solenoid is fundamentally a binary device: energized, it moves to one end of its travel (usually within milliseconds); de-energized, a spring (or gravity, or the load itself) returns it to the other end.
Push vs Pull vs Latching
TypeBehaviorTypical use Pull-typePlunger retracts into the coil body when energized; a spring or external force pushes it back out when power is removedDoor strikes, locks, most general-purpose solenoids Push-typePlunger extends out of the coil body when energizedKickers, pinball-style strikers, ejector mechanisms Push-pullA single coil moves the plunger in one direction; reversing coil polarity (on some designs) or a second coil moves it backApplications needing active return force rather than relying on a spring Latching (bistable)Uses a small permanent magnet so the plunger stays in its last position with zero holding current — a brief pulse of current in either direction switches stateBattery-powered locks, low-power valve control, anywhere continuous holding current isn't acceptable Rotary solenoidConverts the same electromagnetic pull into a rotational snap, typically 25-45 degrees of travelLatch releases, small index mechanismsThe distinction between latching and non-latching solenoids matters more than it looks: a standard pull-type solenoid draws its rated current continuously for as long as it needs to stay engaged, which for anything running on battery power or needing to hold a lock open for more than a few seconds is a real power budget problem. A 12V solenoid drawing 500mA continuously is a 6W constant load — fine plugged into mains, a battery killer left engaged.
Linear Actuators: When You Need More Than On/Off
A linear actuator looks similar from the outside — a rod that extends and retracts — but internally it's a completely different mechanism: a small DC gear motor turning a lead screw, moving the rod at a controlled (if slow) speed over a defined stroke length, typically 2-12 inches for hobbyist-accessible units. Unlike a solenoid's instant snap, a linear actuator takes real time to travel its full stroke (often several seconds), draws current the whole time it's moving rather than the whole time it's holding a position (a lead screw actuator is usually self-locking and holds position with zero current once the motor stops), and can be fitted with a built-in potentiometer or Hall-effect sensor for position feedback.
Choose a solenoid when you need a fast binary snap and don't care about intermediate positions — a lock, a kicker, a valve. Choose a linear actuator when you need controlled travel, an intermediate stop position, or a slow deliberate motion — a camera slider, a periscope mechanism, a motorized vent or damper.
Driving a Solenoid Safely
Solenoid coils are inductive loads, and switching an inductor off generates a voltage spike (back-EMF) that can exceed the supply voltage by a large margin and destroy a driving transistor or microcontroller pin in microseconds if unprotected. This is the same flyback problem covered in the relay guide, and the fix is identical: a flyback diode (a 1N4001-1N4007 or similar) wired backward across the solenoid coil terminals, cathode to the positive supply side, so it conducts the collapsing field's current safely instead of letting it spike back through the driver.
- Never drive a solenoid coil directly from a microcontroller GPIO pin. Solenoid coils typically draw hundreds of milliamps to several amps — far beyond the 20-40mA a GPIO pin can source — and the inductive kickback would destroy the pin regardless.
- Use a logic-level MOSFET or a relay/SSR as the switching element, sized for the solenoid's rated current with margin. A logic-level N-channel MOSFET (gate threshold under 3V, so it switches fully on from a 3.3V GPIO through a gate resistor) is the simplest driver for a DC solenoid.
- Always include the flyback diode directly across the coil terminals, as close to the coil as practical — not back at the driver board, where trace inductance reduces its effectiveness.
- Check the duty cycle rating. Many inexpensive solenoids are rated for intermittent duty only (a stated maximum "on" time, like 10-30% duty cycle) because the coil generates real heat under continuous current and can burn out if held engaged too long. A solenoid lock meant to hold open for extended periods needs either a continuous-duty-rated coil or a latching design.
Driving a Linear Actuator
A linear actuator is, electrically, a DC gear motor — drive it the same way you would any brushed DC motor, through an H-bridge (an L298N, DRV8871, or similar) so you can reverse polarity to extend and retract, rather than a simple one-direction MOSFET switch. Stall current matters more here than with almost any other DC motor application: an actuator that hits the end of its mechanical travel, or an obstruction, will stall and draw several times its running current indefinitely if not stopped, which is a real fire and burnout risk on cheap actuators without internal current limiting.
- If the actuator has a built-in potentiometer or Hall sensor feedback, read it and stop the drive signal well before the actuator can mechanically bottom out — don't rely on the actuator's own end-of-travel clutch (cheap units often don't have one) to save you.
- Add current sensing (an INA219 or a simple shunt resistor, as covered in this site's current sensing guide) on the actuator's supply line if there's no position feedback, and cut drive current if it spikes above the actuator's rated running current for more than a brief startup transient.
- Size the H-bridge driver for stall current, not running current — a 12V actuator that draws 1A running might draw 4-5A stalled, and an underrated driver IC will overheat or fail exactly when something jams.
Sizing and Selection Checklist
- Force rating — solenoids are rated in ounces or newtons of pull/push force at a given stroke position; force typically drops off sharply as the plunger approaches full extension, so check the force curve, not just the peak spec, against your actual load.
- Stroke length — solenoids typically offer 5-25mm of travel; if you need more, a linear actuator is almost certainly the right part instead.
- Voltage and current — 5V and 12V are the common hobbyist voltages; confirm the coil's rated current against what your chosen MOSFET or H-bridge can actually switch.
- Duty cycle — continuous vs intermittent duty, as covered above; check the datasheet, not just the product listing.
- Mechanical mounting — solenoids and actuators both need a rigid mount that resists the reaction force of the plunger's motion; a solenoid mounted to something flexible will visibly deflect the whole assembly instead of just moving the plunger.
Common Problems
SymptomLikely cause Solenoid buzzes or chatters instead of snapping cleanlyInsufficient current (undersized power supply or driver, voltage drop under load) — the plunger is only partially pulling in Driver MOSFET or microcontroller pin fails after repeated cyclesMissing or incorrectly oriented flyback diode Solenoid coil gets hot / smells like burning insulationContinuous-duty use of an intermittent-duty-rated coil, or a stuck/jammed plunger holding the coil energized against resistance Linear actuator draws excessive current and stallsMechanical obstruction or reaching end-of-travel with no position feedback cutting the drive signal in timeSolenoids and linear actuators are simple devices individually, but the electrical side — inductive kickback, duty cycle limits, and stall current — is where projects go wrong. Match the mechanism (fast snap vs controlled travel) to what the project actually needs, drive it through a properly protected MOSFET or H-bridge rather than straight off a GPIO pin, and respect the duty cycle rating on the datasheet rather than the assumption that "it's just a coil, it'll be fine."
Related Guides
- Relays and Solid-State Relays for Makers: Switching AC and DC Loads Safely
- How to Program Addressable LED Strips: WS2812B Patterns, Effects, and Power Design
- I2C vs SPI vs UART: How to Choose and Use Serial Communication Protocols
- How to Use Sensors with Arduino and ESP32: Temperature, Distance, Load, Current, and Hall Effect
- How to Control Motors with Arduino and ESP32: Stepper, DC, and Servo Drivers
- ESP32: Setting Up for Arduino IDE
- Arduino vs ESP32: Which Should You Use? A Practical Comparison
- Getting Started with ESP32: GPIO, WiFi, and Your First Project