Posted on

How to control a linear actuator with an Arduino

Controlling a linear actuator is fun and easy. They’re really strong and can be used for all kinds of things: raising your TV out of a hidden pocket; crushing your enemies; or building an RC backhoe or dump truck. I did this entire project in about 20 minutes for around $150 CAD.

Proof actuator+arduino works. See latest post at

A post shared by Dan Royer (@imakerobots) on

Linear Actuator Circuit Parts

Linear Actuator Circuit Assembly

The board comes with screw terminals and male/male headers unattached. I used my trusty Solomon SR-998 soldering iron to attach them. The board has four large holes for wires that are not the right spacing for the screw terminals. Immediately next to the large holes are pairs of smaller holes that work perfectly.

I then attached the rest of the components. Here’s a simplified circuit diagram.

Actuator circuit
Actuator circuit. Click for larger version.

The female power plug screwed into GND/VIN on the VNH5019 so I could unplug the power supply with ease. You could put switch in here for an E-stop.

The Arduino is powered from the USB connection. For this demo you have to have the USB and the 12v5a power connected. The Arduino can handle 12v so you could get a 12v6a power supply and power everything without a USB. I wanted to keep this simple, but feel free to discuss it in the forums.

Linear Actuator Code

I carefully read the VNH5019 instructions before I made my purchase. You’d do your homework too, right? Right. That’s how I knew what to put in the Arduino code.

Get the code here:

Now you

Did this tutorial help you? Give us a shout on the forums and show your creation. We’d love to share it with the world.

Got questions? See something that could be better? Post below!

13 thoughts on “How to control a linear actuator with an Arduino

  1. How are you controlling the linear actuator? How would you control it remotely?
    Thank you

    1. take a look at the link to the code in the article. This could be changed to listen for commands from the serial line (sent from the PC). Another way would be to use a NodeMCU instead of an arduino, and then you could access it remotely over the internet.

      1. How about using RF?

  2. Could you explain how it could be controlled using a sensor i.e. when object is detected, it moves in one direction, and the reverse direction when there is no object.

    1. The arduino can turn on the power of the h bridge to drive the actuator in or out. The arduino could also listen to a sensor and when the sensor changes state (it detects something) the arduino could then decide what action to take (move actuator in, for example)

  3. Could you control the distance and force applied?

    Could it run out to a certain distance but if there is to much force in the way it would stop, then try again. Say as to change a gear in a gear box.

    1. Out of the box this actuator does not have a distance sensor or a force sensor. Both would need to be added to do what you ask.

  4. Hello Dan,

    I try your tutorial for the electrical actuator. it’s working for the forward, but not for the Backward.

    What happen ?

    I need your help on


    1. post a video of your circuit to the forums and a link to your code. Then maybe I can see the problem.

      1. I am having this same issue, Im using a longer stroke actuator. It slowly moved forward but never back. I used the same wiring and code. I’m jus wondering what i will need to change the code to have this move a bit quicker and backwards in a loop.

        1. What controller are you using? Does the light change when the direction changes? (see video) My guess from no information given is that the direction is not being reversed.

  5. Hi Dan, can you please share the Polulu VNH5019 library you used for Arduino ?
    Thanks in advance.

    1. I don’t remember a library. It was a very short arduino sketch.

Leave a Reply

Your email address will not be published. Required fields are marked *