I am hoping to control a WINDYNATION 4" Stroke Length Linear Actuator with a Raspberry Pi for a senior design group project. Ideally, the program will make the actuator fully extend, and then retract to a very specific variable length to stretch a tissue sample. This is a copy of my current python program, which the actuator responds to, but it still won't both extend the actuator then retract for the variable amount of time in the same run of the program.

import RPI.GPIO as GPIO
from time import sleep


GPIO.setup(motor1A, GPIO.OUT)
GPIO.setup(motorB, GPIO.OUT)
GPIO.setup(motor1E, GPIO.OUT)

print("turning motor on")
GPIO.output(motor1A, GPIO.HIGH)
GPIO.output(motor1B, GPIO.LOW)
GPIO.output(motor1E, GPIO.HIGH)


ratio = input("Enter desired stretch ratio (decimal)")
length = input("Enter sample length (mm)")
variable = (((ratio))*((length))*.01)

print("begin tissue stretch")
GPIO.output(motor1A, GPIO.LOW)
GPIO.output(motor1B, GPIO.HIGH)
GPIO.output(motor1E, GPIO.HIGH)


print("end of tissue stretch")
GPIO.output(motor1E, GPIO.LOW)


Any help anyone might have would be greatly appreciated (for example, a way of programming the actuator based on its inherent orientation, rather than just specific increments of time.

  • Welcome! How about #!/usr/bin/env python for first line?
    – Fabian
    Apr 4, 2018 at 20:27
  • You need a link and a description of your linear actuator.
    – NomadMaker
    Aug 21, 2018 at 12:13
  • Windynation has at least 10 actuators that fit your description. Also, what motor driver are you using for this? My best guess is that you need some form of feedback to let the Pi know what the actuator is doing.
    – NomadMaker
    Aug 21, 2018 at 12:19

1 Answer 1


How about you define a "distance step" (one for extend and one for retract) by toggling the relevant GPIO pins, thus sending a short pulsed signal to the actuator. For example:

def step_motor1E():
    GPIO.output(motor1E, GPIO.HIGH)
    GPIO.output(motor1E, GPIO.LOW)

and similarly for the other motors. If you can measure the amount that this moves your actuator (with a ruler or whatever), you get a "distance per step". Then you can define more general functions to move the actuator to a specific location by combining a given number of "steps" with your calibrated value of "distance per step". As a note, it's definitely worth seeing if your distance per step is repeatable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.