Skip to content
  • There are no suggestions because the search field is empty.

How Do I Control PA Actuator Speed with Arduino PWM?

PWM (Pulse Width Modulation) lets you vary actuator speed from 0 to 100% using Arduino's analogWrite(). This article explains how PWM motor control works and shows complete example code for variable-speed extend and retract.

How PWM Controls Speed

PWM rapidly switches the motor supply on and off. The ratio of on-time to off-time (the duty cycle, expressed 0–255 on Arduino) sets the average voltage delivered to the motor. At 128/255 (50% duty cycle), the motor receives an effective 6 V from a 12 V supply, running at roughly half speed.

⚠️ Don't run at very low PWM values for extended periods At duty cycles below ~20%, the motor may stall (not enough voltage to overcome static friction) while still drawing current — causing heat buildup. If your application needs low-speed creep, use a motor driver with a lower current-limit setting rather than very low PWM.

PWM Speed Control with L298N

// Variable speed actuator control — L298N + Arduino
const int IN1 = 4; // direction A
const int IN2 = 5; // direction B
const int ENA = 6; // PWM speed (must be a PWM pin)

void setup() {
pinMode(IN1, OUTPUT);
pinMode(IN2, OUTPUT);
pinMode(ENA, OUTPUT);
}

// speed: 0–255 (0 = stop, 255 = full speed)
void extendAt(int speed) {
analogWrite(ENA, speed);
digitalWrite(IN1, HIGH);
digitalWrite(IN2, LOW);
}

void retractAt(int speed) {
analogWrite(ENA, speed);
digitalWrite(IN1, LOW);
digitalWrite(IN2, HIGH);
}

void stopMotor() {
analogWrite(ENA, 0);
digitalWrite(IN1, LOW);
digitalWrite(IN2, LOW);
}

void loop() {
extendAt(180); // ~70% speed
delay(3000);
stopMotor();
delay(1000);
retractAt(255); // full speed
delay(3000);
stopMotor();
delay(1000);
}

Speed Control Tips

  • Use PWM pins only:Arduino Uno PWM pins are 3, 5, 6, 9, 10, 11. Using a non-PWM pin meansanalogWrite()outputs only full-on or full-off.
  • Ramp speed gradually:For applications sensitive to shock loads, ramp from 0 to target speed over 200–500 ms instead of switching instantly to full speed.
  • PA's dedicated speed controller:If you don't need microcontroller integration, theAC-26-30 High Current DC Speed Controller(30 A, 12–48 V) provides variable speed control via a built-in knob without Arduino needed.