Control a Linear Actuator with an Arduino

Arduino microcontrollers have revolutionized the world of DIY automation, offering makers and engineers an accessible platform for controlling electronic components with precision. When it comes to integrating linear actuators into your projects—whether you're building a smart home device, a robotic arm, or an automated furniture system—understanding how to properly interface them with Arduino opens up countless possibilities. Unlike simple LED circuits or sensors, linear actuators require careful consideration of power requirements, control logic, and safety mechanisms to operate correctly.

This guide will walk you through the essential components, wiring configurations, and programming techniques needed to control a linear actuator using Arduino. We'll cover the fundamental relay-based control method that enables bidirectional movement, discuss best practices for circuit design, and explore how you can expand upon this basic setup to create sophisticated automation systems. Whether you're working with a compact micro linear actuator for a small project or an industrial actuator for a larger application, the principles remain consistent.

Why You Can't Connect an Actuator Directly to Arduino

Before diving into the solution, it's important to understand the fundamental limitation that prevents direct connection between Arduino and linear actuators. Arduino microcontroller pins typically output 5V at currents up to 40mA per pin, with a maximum total current of 200mA across all pins. In contrast, even small linear actuators typically require 12V or 24V and draw several amperes of current under load—often 2A to 6A or more depending on the model and load conditions.

This massive disparity in voltage and current requirements means that connecting an actuator directly to Arduino pins would either fail to move the actuator at all or, more seriously, damage the Arduino board by attempting to draw more current than the pins can safely provide. The microcontroller's output pins are designed for signaling, not power delivery. This is where intermediate switching components become essential—they act as electrically-controlled switches that allow the Arduino to control high-power circuits without actually carrying that power through its own circuitry.

Relay-Based Control Fundamentals

Relays provide an elegant solution to the power mismatch problem by functioning as electrically-activated mechanical switches. A relay consists of an electromagnetic coil and a set of switch contacts. When the Arduino sends a small control current to energize the coil (typically 30-80mA at 5V), it creates a magnetic field that physically moves the switch contacts, allowing a completely separate high-power circuit to close. This electrical isolation means the Arduino never has to handle the actuator's power requirements directly.

For linear actuator control, we need to accomplish three distinct operations: extend, retract, and stop. Since linear actuators reverse direction based on polarity (reversing the positive and negative connections changes direction), we need a circuit that can dynamically switch the polarity of the voltage supplied to the actuator. This requires two Single-Pole Double-Throw (SPDT) relays configured in an H-bridge-like arrangement.

Understanding SPDT Relays

A Single-Pole Double-Throw relay has three terminals on the switch side: a common terminal (COM), a normally closed terminal (NC), and a normally open terminal (NO). When the relay coil is not energized, the common terminal connects to the normally closed terminal. When you energize the coil, the connection switches from NC to NO. By using two of these relays strategically positioned in your circuit, you can route power to your actuator in either forward or reverse polarity.

In the configuration demonstrated in this guide, one relay controls the connection to the positive voltage supply, while the second relay controls the connection to ground. By activating the relays in different combinations, you can create three states: extend (relay 1 active), retract (relay 2 active), and stop (neither relay active).

Required Components and Circuit Setup

To build a functional Arduino-controlled linear actuator system, you'll need the following components:

  • Arduino Board: Arduino Uno, Nano, or any compatible board with at least 4 digital I/O pins
  • Two SPDT Relays: Rated for at least 10A at your actuator's operating voltage (12V or 24V typically)
  • Linear Actuator: Any DC motor-based actuator from FIRGELLI's range, such as bullet actuators or track actuators
  • Power Supply: Matched to your actuator's voltage requirements (12V or 24V), with sufficient current capacity
  • Two Push Buttons: For manual control inputs
  • Diodes: 1N4007 or equivalent flyback diodes for each relay coil to protect against voltage spikes
  • Resistors: 10kΩ pull-up resistors for button inputs
  • Connecting Wires: Appropriate gauge for the actuator current (typically 18-22 AWG for most applications)

Wiring Configuration

The wiring setup requires careful attention to ensure both proper functionality and safety. On the control side, connect Arduino pin 7 to the control terminal of the first relay and pin 8 to the control terminal of the second relay. Each relay coil should have a flyback diode installed across it (cathode to the positive side) to prevent inductive kickback from damaging the Arduino when the relay switches off.

For the input buttons, connect one button between pin 2 and ground, and the second button between pin 3 and ground. The Arduino's internal pull-up resistors can be enabled in code to hold these pins HIGH when the buttons aren't pressed, pulling them LOW when pressed. This configuration is standard practice for digital inputs and provides reliable button detection without external resistors.

On the power side, connect your power supply positive terminal to the common terminal of the first relay, and the normally open contact of that relay to one terminal of the actuator. Connect the power supply ground to the common terminal of the second relay, and its normally open contact to the other terminal of the actuator. This arrangement allows the relays to switch both the positive and negative connections to the actuator independently.

Arduino Programming and Control Logic

The Arduino code for basic relay control is straightforward but requires attention to relay behavior. Many relay modules operate on active-low logic, meaning they energize when their control pin is set to LOW rather than HIGH. This is the configuration used in this setup and should be verified against your specific relay module's specifications.

Basic Control Code Structure

The program begins by defining the pin assignments as constants, making the code more readable and maintainable. In the setup function, configure pins 2 and 3 as inputs with internal pull-up resistors enabled, and pins 7 and 8 as outputs initially set HIGH (which keeps active-low relays in their off state).

In the main loop, the program continuously reads the state of both input buttons. When the extend button (pin 2) is pressed, the input reads LOW, triggering the Arduino to set pin 7 LOW, which energizes the first relay and causes the actuator to extend. When the retract button (pin 3) is pressed, pin 8 is set LOW, energizing the second relay and reversing the actuator's direction. When neither button is pressed, both relay control pins return to HIGH, de-energizing both relays and stopping the actuator.

Safety Considerations in Code

A critical aspect of actuator control is preventing both relays from being energized simultaneously. If both relays activate at once, you create a short circuit directly from positive to ground through the relays—a condition that can damage components or create a fire hazard. While the basic code structure naturally prevents this in simple button operation, any more complex control logic should explicitly check that only one relay is active at a time.

Additionally, consider implementing limit switch logic if your actuator doesn't have built-in limit switches. You can add mechanical switches at the full extension and retraction points, wiring them to additional Arduino inputs, and program the code to automatically stop the actuator when these switches are triggered.

Advanced Control Techniques

Once you've mastered basic relay control, numerous advanced techniques can enhance your actuator control system's capabilities.

Position Feedback Control

Standard linear actuators operate open-loop—you tell them to move, and they move until you tell them to stop or they hit a limit. For applications requiring precise positioning, consider upgrading to feedback actuators that include built-in potentiometers or hall effect sensors. These provide a voltage or pulse signal that corresponds to the actuator's position, which you can read with Arduino's analog inputs.

With position feedback, you can implement closed-loop control, allowing the Arduino to automatically move the actuator to specific positions. This enables creation of preset positions, automatic calibration routines, and load compensation that adjusts for varying mechanical resistance.

PWM Speed Control

While relays provide simple on/off control, they don't allow speed modulation. For applications requiring variable speed control, you can substitute the relay circuit with a motor driver IC or MOSFET H-bridge that supports PWM (Pulse Width Modulation) input. Arduino can output PWM signals that effectively vary the average voltage supplied to the actuator, controlling its speed from full stop to maximum velocity.

This technique is particularly valuable when working with Arduino-compatible components designed specifically for motor control, such as L298N or IBT-2 motor driver modules. These integrated solutions handle the high-power switching internally while accepting logic-level control signals from Arduino.

Wireless and Remote Control

The basic wired button setup can be expanded to wireless control by incorporating Bluetooth, WiFi, or RF modules with your Arduino. A Bluetooth module like the HC-05 allows smartphone control through custom apps, while WiFi modules like the ESP8266 or ESP32 enable internet-connected control and integration with home automation systems. Alternatively, FIRGELLI offers dedicated remote control solutions for more plug-and-play applications.

Practical Applications and Project Ideas

Arduino-controlled linear actuators enable a vast range of automation projects across different domains. In home automation, they're ideal for motorizing window blinds, creating automated pet feeders with adjustable heights, or building TV lift mechanisms that hide screens when not in use. The precise control offered by Arduino programming allows for scheduled operations, sensor-triggered movements, and integration with smart home ecosystems.

For robotics and mechanical projects, linear actuators controlled by Arduino provide the linear motion needed for grippers, legs in walking robots, camera sliders for photography, and adjustable mounting systems. The ability to coordinate multiple actuators through a single Arduino board makes it possible to create complex synchronized movements for anthropomorphic robots or multi-axis positioning systems.

In furniture and ergonomic applications, Arduino control enables creation of custom standing desk controllers with memory positions, automated cabinet doors, or adjustable workbenches that respond to user presence or scheduled height changes throughout the day. These applications benefit particularly from position feedback control, allowing precise and repeatable positioning.

Troubleshooting Common Issues

When working with Arduino-controlled actuators, several common issues may arise. If your actuator doesn't move at all, first verify that your power supply is providing adequate voltage and current. Use a multimeter to check voltage at the actuator terminals when the relay is energized. Also confirm that relay coils are energizing—most relay modules include LED indicators that illuminate when active.

If the actuator moves in only one direction, check your relay wiring carefully. The polarity switching circuit requires precise connections, and a single swapped wire can prevent directional control. Verify that both relays are receiving control signals from the Arduino by testing the voltage at each relay control input when buttons are pressed.

Erratic behavior or random movements often indicate electrical noise or insufficient power supply filtering. Linear actuators generate electrical noise when switching, which can interfere with Arduino operation if proper grounding isn't maintained. Ensure all ground connections are solid, consider adding capacitors across the power supply (100μF or larger), and keep actuator power wiring separated from control signal wiring where possible.

If the Arduino resets when the actuator activates, your power supply likely lacks sufficient current capacity or you're experiencing voltage drops. Linear actuators draw surge currents during startup that can be significantly higher than running current—sometimes 2-3 times higher for a fraction of a second. Ensure your power supply is rated for at least 150% of the actuator's nominal current draw, and consider using separate power supplies for the Arduino and actuator if problems persist.

Selecting the Right Actuator for Arduino Projects

Choosing an appropriate linear actuator for your Arduino project requires consideration of several key specifications. Force rating is primary—actuators are rated in pounds (lbs) or Newtons (N) of push/pull force. Calculate the actual force required for your application, including any friction, inertia, or resistance, and select an actuator rated for at least 150% of that force to ensure reliable operation with a safety margin.

Stroke length determines the total distance the actuator can travel. Measure the full range of motion needed for your application and select a stroke length that accommodates it. Remember that actuators are typically sold in standard stroke lengths (2", 4", 6", 8", 10", 12", etc.), so you may need to select the next larger size if your exact requirement falls between standard options.

Speed is typically measured in inches per second (ips) or millimeters per second (mm/s). Faster actuators complete movements more quickly but generally provide less force—there's an inverse relationship between speed and force in actuator design. For most Arduino projects, speeds between 0.5 and 2 ips provide a good balance of performance and control precision.

Voltage and current requirements must match your available power supply and relay capabilities. Most FIRGELLI actuators operate on 12V DC, making them compatible with common power supplies and automotive applications, though 24V models are available for applications requiring higher power. Check the current draw specifications and ensure your relays, wiring, and power supply can handle the maximum current.

Conclusion

Controlling linear actuators with Arduino opens up a world of automation possibilities for makers, hobbyists, and professional engineers alike. While the basic relay-based control method provides a solid foundation for simple extend/retract operations, the true power of Arduino integration lies in the ability to implement sophisticated control algorithms, position feedback, and multi-actuator coordination. By understanding the fundamental principles of electrical isolation, proper power handling, and control logic, you can create reliable automation systems that range from simple one-off projects to complex mechatronic systems. Whether you're just starting with a basic push-button setup or planning an advanced feedback-controlled positioning system, the techniques covered in this guide provide the essential knowledge needed to successfully integrate linear actuators into your Arduino projects.

Frequently Asked Questions

Can I control multiple actuators with one Arduino?

Yes, you can control multiple actuators with a single Arduino board. An Arduino Uno has 14 digital I/O pins, allowing you to control up to 7 actuators using the two-relay method (2 pins per actuator). For larger installations, consider using relay modules with built-in multiplexing, or upgrade to Arduino Mega which offers 54 digital I/O pins. When controlling multiple actuators, pay careful attention to total current draw on the power supply—each actuator's current requirements are additive. Also ensure your code prevents conflicting commands if actuators share mechanical connections or could interfere with each other's operation.

Do I need feedback actuators for position control, or can I use timing?

While you can implement basic position control using timing methods with standard actuators—measuring how long the actuator runs to estimate position—this approach has significant limitations. Timing-based control doesn't account for varying loads, voltage fluctuations, mechanical wear, or startup delays, leading to position drift over time. For any application requiring repeatability or precision, feedback actuators with built-in position sensors are strongly recommended. These provide real-time position data that enables closed-loop control, allowing the Arduino to automatically compensate for variables and achieve accurate positioning within ±1% or better of the stroke length.

What is the maximum distance between the Arduino and the actuator?

The distance limitation depends on which signals you're extending. Control signals from Arduino to relays can typically run 15-20 feet using standard hookup wire before signal degradation becomes problematic, though this distance can be extended using shielded cable or by placing the relay module near the actuator rather than near the Arduino. The high-power wiring between the power supply, relays, and actuator should be kept as short as practical—long power runs create voltage drops and power loss. As a general rule, keep actuator power wiring under 10 feet, and if longer distances are necessary, increase wire gauge to compensate (every 3 feet requires approximately one AWG size increase). For remote installations, consider using wireless control methods or placing the entire control circuit near the actuator with only low-power communication to the main controller.

Can I use a motor shield instead of relays for actuator control?

Yes, motor shields or H-bridge motor driver modules are excellent alternatives to relay-based control and offer several advantages. Products like the Arduino Motor Shield, L298N modules, or IBT-2 high-current drivers can handle the bidirectional control needed for linear actuators while also enabling PWM speed control—something relays cannot provide. Motor shields are often more compact than relay modules and switch faster without the mechanical click of relays. However, ensure the motor shield is rated for your actuator's current requirements; some shields designed for hobby motors may only handle 2A per channel, which is insufficient for larger actuators. For industrial-grade actuators drawing 5A or more, stick with appropriately rated relay modules or specialized high-current motor drivers designed for industrial applications.

How do I add limit switches to prevent over-extension or over-retraction?

Adding external limit switches provides an important safety mechanism for actuators without built-in limits. Mount normally-closed (NC) limit switches at the full extension and full retraction points of your actuator's travel path, positioned so the actuator or its load triggers them just before reaching the mechanical end stops. Wire these switches in series with the actuator's power supply—the extension limit switch interrupts power during extension, and the retraction limit switch interrupts power during retraction. Connect the switches' state to Arduino input pins so your code can detect when limits are reached and prevent further movement in that direction. This creates a redundant safety system where mechanical switches provide fail-safe protection while Arduino code provides intelligent limit handling. Many FIRGELLI industrial actuators include built-in limit switches, eliminating the need for external switches and simplifying installation in applications requiring robust mechanical protection.

Share This Article
Tags: