Arduino - Actuator
In this tutorial, we are going to learn:
- How linear actuator works
- How to make linear actuator extend or retract.
- How to control a linear actuator using BTS7960 driver and Arduino.
- How to control the speed of a linear actuator.
This tutorial is for linear actuator without feedback. If you want to learn about linear actuator with feedback, see this Arduino - Actuator with Feedback tutorial.
Hardware Required
Or you can buy the following kits:
| 1 | × | DIYables STEM V3 Starter Kit (Arduino included) | |
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some links direct to products from our own brand, DIYables .
About Linear Actuator

Linear Actuator Pinout
Linear Actuator has two wires:
- Positive wire: usually red
- Negative wire: usually black

How It Works
When you buy a linear actuator, you need to know what voltage linear actuator works. Let's take a 12V linear actuator as an example.
When you power the 12V linear actuator by a 12V power source:
- 12V and GND to the positive wire and negative wire, respectively: the linear actuator full-speed extends until it reaches the limit.
- 12V and GND to the negative wire and positive wire, respectively: the linear actuator full-speed retracts until it reaches the limit.
While extending or retracting, if we stop power to the actuator (GND to both positive and negative wire), the actuator stops extending/retracting
※ NOTE THAT:
For DC motor, servo motor, and stepper motor without gearing, when carrying a load, if we stop powering, they cannot keep the position. Unlike these motors, the actuator can keep the position even when stopping powering while carrying a load.
If we provide power to linear actuators below 12V, the linear actuator still extends/retracts but not at maximum speed. It means if we change the voltage of the power supply, we can change the speed of the linear actuator. However, this method is not used in practice because of the difficulty in controlling the voltage of the power source. Instead, we fix the voltage of the power source and control the speed of the linear actuator via a PWM signal. The more duty cycle the PWM is, the higher speed the linear actuator extends/retracts.

How to control a linear actuator using Arduino
Controlling a linear actuator includes:
- Extends the linear actuator at maximum speed.
- Retracts the linear actuator at maximum speed.
- (optional) controls the extending/retracting speed
Arduino can generate the signal to control the linear actuator. However, this signal has low voltage and current, We cannot use it to control the linear actuator. We need to use a hardware driver in between Arduino and linear actuator. The driver does two works:
- Amplify the control signal from Arduino (current and voltage)
- Receive the another control signal from Arduino to swap pole of power supply → for direction control.
※ NOTE THAT:
- This tutorial can be applied to all linear actuators. 12V linear actuator is just an example.
- When you controls 5V linear actuator, although Arduino pin outputs 5V (the same as linear actuator voltage), you still needs a driver in between Arduino and linear actuator because the Arduino pin does not provide enough the current for linear actuator.
Many chips and modules can drive a linear actuator, for example the L293D or the BTS7960. In this tutorial, we will use the BTS7960 driver. We chose it because a linear actuator needs a burst of current at the start of each move, and again when it stalls at the end of its stroke.
※ NOTE THAT:
You can also use relays as a driver. However it requires 4 relays to control a single linear actuator (both extend/retract)
About BTS7960 Driver
The BTS7960 driver (also sold as IBT-2) is a strong driver for one DC motor or one linear actuator. Inside, it has two BTS7960B half-bridge chips. Together they make one H-bridge, so the actuator can move both ways. In this tutorial, we learn how to use it to control the linear actuator.
BTS7960 Driver Pinout

There is only one channel on the BTS7960, so one module moves one linear actuator. The signals use a header with 8 pins, and the power wires use a screw terminal with 4 pins.
The header pins:
- RPWM pin: a PWM signal here makes the linear actuator extend. It needs to be connected to a PWM pin of Arduino.
- LPWM pin: a PWM signal here makes the linear actuator retract. It needs to be connected to another PWM pin of Arduino.
- R_EN & L_EN pins: the enable pins of the right and left half-bridges. HIGH = on, LOW = off. They need to be connected to two pins of Arduino.
- R_IS & L_IS pins: give a signal that follows the motor current. This tutorial leaves them free.
- VCC pin: supplies power for the small logic chip on the module. It needs to be connected to the 5V pin of Arduino.
- GND pin: is a common ground pin, needs to be connected to GND of Arduino.
The screw terminal pins:
- B+ & B- pins: supply power for the linear actuator. It can be anywhere between 5.5V and 27V. In this tutorial, we use 12V.
- M+ & M- pins: are connected to the two wires of the linear actuator.
As described above, the BTS7960 driver has two input powers:
- One for the linear actuator (B+ and B- pins): from 5.5V to 27V.
- One for the logic chip of the module (VCC and GND pins): 5V from Arduino.
The control pins accept 3.3V and 5V signals. They also have pull-down resistors, so the driver stays off while Arduino starts. The module can give up to 43A for short peaks, and it loses almost no voltage, so the actuator gets almost the full 12V.
We need four pins from Arduino to control one linear actuator: two PWM pins for direction and speed, and two pins to enable the driver.
How To Control Linear Actuator
We will learn how to control Linear Actuator using BTS7960 driver
Wiring Diagram
The BTS7960 gets the 12V for the actuator through the DC power jack. Arduino only sends the control signals and gives 5V to the VCC pin of the module.

This image is created using Fritzing. Click to enlarge image
| BTS7960 Pin | Connect To |
|---|---|
| RPWM | Arduino pin 9 |
| LPWM | Arduino pin 10 |
| R_EN | Arduino pin 12 |
| L_EN | Arduino pin 11 |
| VCC | Arduino 5V |
| GND | Arduino GND |
| R_IS, L_IS | not connected |
| B+ | + of the 12V power adapter (via DC power jack) |
| B- | - of the 12V power adapter (via DC power jack) |
| M+, M- | the two wires of the linear actuator |
When the actuator moves, it can pull on the wires. To keep them tight, plug a Proto Screw Terminal Block Shield or a Screw Shield V2 into the Arduino Uno and fix each wire with a screw. The pins stay the same, as the next image shows.

This image is created using Fritzing. Click to enlarge image
How To Make Linear Actuator Expand/Retract
First, set R_EN and L_EN pins to HIGH to turn the driver on. Then, the moving direction of a Linear Actuator is controlled by the RPWM and LPWM pins. The below table shows the states of these two pins.
| RPWM pin | LPWM pin | Direction |
|---|---|---|
| 0 | 0 | Linear Actuator stops |
| 255 | 0 | Linear Actuator extends |
| 0 | 255 | Linear Actuator retracts |
- Turns the driver on
- Extends Linear Actuator
- Retracts Linear Actuator
※ NOTE THAT:
- The moving direction is inverted if the M+ & M- pin connects to two pins of the linear actuator in an inverse way. If so, it just needs to swap between M+ & M- pin or swap RPWM and LPWM pin in the code.
- Keep one of the two PWM pins at 0 at all times. Do not give both RPWM and LPWM a PWM value together.
How To Stop Linear Actuator from Extending or Retracting
The linear actuator automatically stops extending/retracting when it reaches the limit. We can also programmably stop it from extending/retracting while it has not reached the limit.
There are two ways to stop linear actuator
- Set both RPWM and LPWM to 0 (brake). The driver joins the two actuator wires, so it stops quickly.
- Set R_EN and L_EN pins to LOW. Both half-bridges switch off, and the actuator rolls on for a moment before it stops (coast).
How To Control the Speed of Linear Actuator via BTS7960 Driver
It is simple to control the speed of the linear actuator. We just give RPWM or LPWM a PWM value below 255. We can do this by:
- Connect the RPWM and LPWM pins of BTS7960 to two PWM pins of Arduino
- Generate PWM signal to RPWM pin (to extend) or LPWM pin (to retract) by using analogWrite() function. The other pin stays at 0. The BTS7960 driver amplifies the PWM signal to the linear actuator
The speed is a value between 0 and 255. If the speed is 0, the linear actuator stops. If the speed is 255, the linear actuator extends/retracts at maximum speed.
Arduino Example Code
The below code does:
- Extend actuator at maximum speed
- Stop the linear actuator
- Retract actuator at maximum speed
- Stop the linear actuator
Quick Steps
- Do the wiring as in the diagram above. Plug in the 12V power adapter after you upload the code.
- Copy the above code and open with Arduino IDE
- Click Upload button on Arduino IDE to upload code to Arduino
- You will see:
- Linear actuator extends and then stops when reaching the limit
- Linear actuator keeps the position a mount of time
- Linear actuator retracts and then stops when reaching the limit
- Linear actuator keeps the position a mount of time
- The above process is run repeatedly.
Video Tutorial
We are considering to make the video tutorials. If you think the video tutorials are essential, please subscribe to our YouTube channel to give us motivation for making the videos.