Raspberry Pi Pico - Actuator with Feedback
In a previous tutorial, we learned about how to use Raspberry Pi Pico with a linear actuator without feedback. In this tutorial, we will learn how to use Raspberry Pi Pico with the linear actuator with feedback. The feedback signal from the actuator tells provides its position during movement, which helps us control where it goes. We will examine the following details:
- How a feedback linear actuator works.
- How to program Raspberry Pi Pico to read the position of a feedback linear actuator.
- How to program Raspberry Pi Pico to control the position of a feedback linear actuator.
Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of Feedback Linear Actuator
A feedback linear actuator is a device that moves in a straight line and includes a system to check and adjust its position. It uses a potentiometer that sends out a voltage signal relating to where the actuator is positioned.
Feedback Linear Actuator Pinout
A feedback linear actuator comes with five wires.
- Positive Wire: This wire uses a high voltage (12V, 24V, 48V) to control the linear actuator.
- Negative Wire: This wire uses a high voltage (12V, 24V, 48V) to control the linear actuator.
- 5V Wire: Connect this wire to the feedback potentiometer at 5V or 3.3V.
- GND Wire: Connect this wire to the feedback potentiometer at the ground (GND).
- Potentiometer Wire: Also called the feedback or output wire, this wire changes its voltage value according to the stroke position.

How It Works
When we apply a high voltage to the positive and negative wires, the actuator will either stretch out or pull back. To explain this, if we connect:
- Connect 12V (or 24V, 48V) to the positive wire and GND to the negative wire: the actuator will extend at its highest speed until it fully extends.
- Connect 12V (or 24V, 48V) to the negative wire and GND to the positive wire: the actuator will retract at its highest speed until it fully retracts.
- If the actuator's power is switched off (by connecting GND to both its wires) while it is extending or retracting, it will stop moving.
※ NOTE THAT:
- The voltage required to operate the actuator depends on its specific features. Look at the datasheet or manual to determine the correct voltage.
- The actuator can keep its position without electricity, even when supporting a weight.
The voltage in the potentiometer's wire changes when the actuator moves. By measuring this voltage, we can determine the position of the stroke.
BTS7960 Driver
The Pico moves the actuator through a BTS7960 driver module (IBT-2). Inside it, two BTS7960B half-bridge chips make one full H-bridge, which is just right for one actuator. Its strong outputs handle the big current that an actuator pulls at each end of its stroke, and they waste almost no voltage, so the actuator gets nearly the full 12V.

- RPWM: PWM or HIGH here = the actuator extends.
- LPWM: PWM or HIGH here = the actuator retracts. RPWM and LPWM both at 0 = brake.
- R_EN and L_EN: the driver does nothing until the Pico sets both of these enable pins HIGH.
- VCC and GND: VCC takes 5V for the buffer chip on the board. The inputs are happy with the 3.3V signals of the Pico.
- B+ and B-: the 12V actuator supply (5.5V to 27V is allowed).
- M+ and M-: the positive and negative wires of the actuator.
- R_IS and L_IS: not used.
Wiring Diagram

This image is created using Fritzing. Click to enlarge image
| Part Pin | Raspberry Pi Pico Pin |
|---|---|
| BTS7960 RPWM | GP16 (pin 21) |
| BTS7960 LPWM | GP17 (pin 22) |
| BTS7960 R_EN | GP19 (pin 25) |
| BTS7960 L_EN | GP18 (pin 24) |
| BTS7960 VCC | VBUS (pin 40) |
| BTS7960 GND | GND |
| Actuator potentiometer wire | GP26 (pin 31) |
| Actuator 5V wire | 3V3(OUT) (pin 36) |
| Actuator GND wire | GND |
- The actuator's 5V wire goes to 3.3V, not 5V. Then the potentiometer wire stays below 3.3V, which is safe for the analog pin of the Pico.
- Connect the actuator's motor wires to the BTS7960: positive into M+, negative into M-.
- B+ and B- go to the + and - terminals of the DC power jack (12V power adapter).
- VBUS gives 5V only when the Pico is powered by USB.
How to control extend/retract a linear actuator
Learn about the Raspberry Pi Pico Actuator by clicking here.
How to find the position of the linear actuator
Here's how to locate the stroke position on a linear actuator:
Calibration
- Use a ruler to find out how long the actuator moves or look at the datasheet for details.
- Plug the 12V power adapter into the DC power jack.
- To see the values when the linear actuator is fully open or closed, run this code.
- You will see the record in the Shell at the bottom of Thonny like in the example below.
- Write these values.
- If the minimum value is more than the maximum value, exchange RPWM_PIN with LPWM_PIN.
- Change three values in the following code.
Raspberry Pi Pico code that calculate the position of the actuator
- Modify the three altered values in the code
- Upload the code to the Raspberry Pi Pico
- Check out the results in the Shell at the bottom of Thonny