DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
Bettesworth Construction
Arduino

How to Control a Linear Actuator Using a Light Sensor

Build a safer light-controlled linear actuator system with an Arduino, calibrated LDR, separate motor supply, correctly rated driver, hysteresis, timeout, and optional position feedback.

By Bettesworth Construction Team 10 min read

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use the light sensor as an input—not as a power source. The reliable arrangement is light sensor → Arduino → high-current motor driver → linear actuator, with a separate DC supply for the actuator. A single sensor can make an actuator extend when it is dark and retract when it is bright; it cannot track the sun’s direction.

How the system works

A photoresistor or phototransistor produces a low-power electrical signal that the Arduino measures. The Arduino then commands an H-bridge, relay arrangement, or dedicated actuator controller. That driver switches the actuator’s higher-voltage, higher-current supply.

As an Amazon Associate I earn from qualifying purchases.

Light sensor → Arduino analog input → motor driver → linear actuator
                                      ↑
                              separate DC supply

For a typical two-wire DC actuator, direction changes when the polarity on its motor wires is reversed. One direction extends the rod; the opposite direction retracts it. The exact supply voltage and current depend on the actuator. Models may use 12 V, 24 V, or another rating, and some light-duty units draw approximately 2–6 A with higher current possible at startup or stall. Check the model datasheet before selecting the supply or driver. Firgelli’s actuator-control guide explains the polarity-reversal arrangement and current requirements.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What kind of actuator do you have?

Do not assume that every product called a linear actuator uses the same wiring.

#1 Best Overall
VEVOR 2PCS Linear Actuator Kit, 30 Inch High Speed 0.35"/s Linear Motion Actuator 110V, 220lbs/1000N Linear Actuator for TV/Table/Sofa Lifting, IP54 Protection - Wireless Remote Control Included
  • All-in-One Electric Actuator Kit: VEVOR linear actuator kit includes everything you need for setup without additional purchases, providing powerful 220lbs/1000N torque for reliable performance in both residential and industrial applications, like lifting platforms and motorized doors and windows
  • Extended Motion Capability: With a generous 30-inch (760mm) stroke, our electric linear actuator kit provides a longer range of motion, making it suitable for tasks requiring extensive movement.
  • Low-Noise, High Versatility: With a noise level below 60db, our linear motion actuator seamlessly fits into various applications, from furniture to automation systems, mechanical equipment, transportation and more. It's versatile and ready for various tasks.
  • Low-Noise, High Versatility: With a noise level below 60db, our linear motion actuator seamlessly fits into various applications, from furniture to automation systems, mechanical equipment, transportation and more. It's versatile and ready for various tasks.
  • Key Specifications: Stroke Length: 30 inch (760mm); Travel Speed: 0.35 in/s (9mm/s); Retracted Length: 34.84" (885mm); Extended Length: 64.84" (1645mm); Input Voltage: AC100-240V; Duty Cycle: 25%. Efficiency is at its highest when the actuation force is approximately 75% of its maximum value.
Actuator type Control method What to verify
Two-wire DC actuator Reverse motor polarity with an H-bridge, DPDT arrangement, or two SPDT relays Voltage, running and stall current, duty cycle, internal limits
Feedback actuator Use a motor driver plus a potentiometer, Hall-effect, or optical feedback input Feedback wiring, voltage range, calibration, and controller compatibility
Actuonix linear servo Follow the model-specific controller or feedback interface Whether the model has an integrated controller and which signals it accepts

For example, some Firgelli feedback actuators use a separate two-wire motor connection and a three-wire, 10-kΩ position potentiometer. That is a model-specific interface, not a universal actuator standard. See the manufacturer’s feedback-actuator documentation. Actuonix also provides model-specific Arduino guidance.

Parts for a practical reference build

  • A 5-V Arduino-compatible board, such as the Arduino UNO R4 Minima.
  • An LDR/photoresistor or phototransistor.
  • A fixed resistor, commonly 10 kΩ as a starting value for an LDR divider.
  • A DC linear actuator rated for the intended load and environment.
  • A high-current H-bridge, two-relay polarity reverser, or dedicated actuator controller.
  • A separate actuator power supply matching the actuator voltage and current requirements.
  • A fuse or resettable overcurrent device placed close to the actuator supply.
  • Optional external limit switches, position feedback, emergency-stop disconnect, enclosure, and weatherproof cable glands.

The UNO R4 Minima is a 5-V logic board with six analog inputs, six PWM-capable pins, and an 8-mA DC-current rating per I/O pin. Its VIN input range does not mean that 12 V may be connected to a sensor or logic pin. Arduino’s technical documentation lists the board’s power details.

Wire the light sensor

An LDR is normally used in a voltage divider. One workable arrangement is:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
5 V ── LDR ──┬── A0
             |
           10 kΩ
             |
            GND

The Arduino reads the junction voltage with its analog input. The reading may increase or decrease as the light gets brighter depending on which component is on top, the board, and the circuit arrangement. Measure the real readings rather than copying a threshold from another project.

Upload this calibration sketch with the actuator disconnected:

const int LIGHT_PIN = A0;

void setup() {
  Serial.begin(115200);
}

void loop() {
  Serial.println(analogRead(LIGHT_PIN));
  delay(250);
}

Open the Serial Monitor at 115200 baud. Record the values in the actual bright and dark conditions—behind the intended cover or enclosure if one will be used. Choose thresholds with a gap between them. A 10-kΩ resistor is a convenient starting point, not a universal requirement; changing it can improve the usable range for a particular LDR.

Never connect the actuator to an Arduino pin

Do not connect either actuator motor wire directly to an Arduino I/O pin. A motor is a high-current inductive load. Arduino pins provide logic signals and cannot supply the actuator’s motor voltage or current. They can also be damaged by motor transients.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
1x for Linear Garage Door Sensor Beam Eyes Kit, HAE00002, LSO50 LDO33 LDO50
  • COMPATIBLE WITH LINEAR OPENERS – Designed as an aftermarket replacement for Linear HAE00002 safety beam sensors used with LSO50, LDO33 and LDO50 garage door openers. Not universal. Verify the model number on your garage door opener before ordering.
  • SENDER + RECEIVER SENSOR SET – Includes one sending sensor, one receiving sensor, attached wire leads, wire connectors and installation instructions for one garage door. Mounting brackets are not included; reuse your compatible existing sensor brackets.
  • PHOTO-EYE SAFETY SYSTEM – The sender and receiver create an invisible infrared beam across the garage door opening. If the beam is interrupted while the door is closing, the opener's safety system is designed to stop or reverse the door.
  • RESTORE PROPER CLOSING OPERATION – Faulty or misaligned safety sensors can cause a Linear garage door to reverse, refuse to close from the remote, or close only while the wall control is held. Check sensor alignment, lenses, wiring and connections before replacing the sensors.
  • VERIFY YOUR PART BEFORE ORDERING – HAE00002 is the legacy Linear safety-beam part number and HAE00087 is its current successor. This aftermarket kit is intended for HAE00002 applications including LSO50, LDO33 and LDO50; confirm your opener model rather than ordering by appearance alone.

The Arduino output pins should drive only the selected driver’s logic inputs. The actuator must receive power from the separate, properly fused supply through that driver.

Choose the actuator driver

High-current H-bridge

An H-bridge is usually the best choice for frequent operation, electronic direction control, or PWM speed control. Select one rated above the actuator’s operating, startup, and stall currents, at the actuator’s voltage, with suitable thermal performance and duty-cycle capability. A BTS7960/IBT-2-style board may be appropriate for some installations, but its actual rating and cooling must be checked against the actuator. The referenced Arduino actuator material shows this type of interface.

Do not choose an L298N merely because it is common in beginner kits. Voltage loss, heat, and current limitations can make it unsuitable for a full-size multi-ampere actuator.

Two SPDT relays

Two SPDT relays can reverse polarity for simple extend, retract, and stop behavior. This is suitable when the actuator moves occasionally and PWM is unnecessary. Relays are mechanically slower, click during operation, wear over time, and can generate electrical noise. Their logic must ensure that conflicting direction commands cannot be active together. Do not reverse polarity while the motor is moving unless the actuator and controller explicitly permit it. Firgelli documents the two-relay approach.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Dedicated actuator controller

Choose a dedicated controller for unattended, exposed, expensive, hazardous, or mechanically complex installations. Controllers may provide current protection, position handling, feedback compatibility, multiple-actuator coordination, and simpler high-level commands. Compatibility depends on the actuator and feedback type; see the manufacturer’s controller and actuator information.

Functional H-bridge wiring

H-bridge boards do not share one universal pinout. Connect the functions according to the driver’s own datasheet:

12-V supply positive  → H-bridge motor supply+
12-V supply negative  → H-bridge motor supply−
Actuator motor wire 1  → H-bridge output A
Actuator motor wire 2  → H-bridge output B
Arduino ground         → H-bridge logic ground
Arduino EXTEND pin     → H-bridge input 1
Arduino RETRACT pin    → H-bridge input 2
Optional PWM pin       → H-bridge enable/PWM input

Some boards use RPWM and LPWM; others use IN1, IN2, and EN. Inputs may be active-high or active-low, and some boards require a standby pin or PWM even for basic operation. Confirm the safe stop state before connecting the actuator. If the interface is not isolated, the Arduino and driver normally need a common logic ground.

Rank #3
JQDML Reciprocating Cycle Linear Actuator 24V 120RPM, Max 40 lbs Thrust
  • 【Specification】Model:24V150mm120rpm.Stroke adjustable: 1.18in-6in;Great range of speed:25-120RPM(no load);Pushing Force: 3-40lbs(40lbs pushing force only at max speed,min stroke).
  • 【Adjustable Stand Angle】Upgraded stand kit with enlarged handle,double screw fixing,which make the stand more convenient to adjust the angle.It can be adjusted from 0 to 180 degree freely,working vertically or horizontally.
  • 【Features】There are three mounting holes on the motor board, with screws included which convenient for fixing.The front end M8 Thread Rod which can be installed according to DIY needs.
  • 【Convenient Design】The speed controller has a speed dial and an “off” button, so you can easily adjust the speed and turn the machine on or off.
  • 【Package Included】1 x Reciprocating Cycle Linear Actuator, 1 x Upgraded Stand Kit,1 x Speed Controller and 1 x 10cm Diameter Suction Cup.

Test direction before adding light control

First test the driver with the actuator unloaded and mechanically clear. Confirm that one command extends and the other retracts. If the direction is reversed, swap the two motor wires or invert the software mapping—wire colors are not universal.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Start with both direction commands off. Never allow both direction paths to be active simultaneously. Before changing direction, turn both commands off, wait for the motor to stop, then apply the new direction. The appropriate pause depends on the driver and mechanism, so use the driver documentation and validate it safely.

Use calibrated thresholds and hysteresis

One threshold causes chatter when the reading hovers around it. Use separate dark and bright thresholds:

  • Below DARK_THRESHOLD: move toward the dark-state position.
  • Above BRIGHT_THRESHOLD: move toward the bright-state position.
  • Between them: retain the current target or stop, depending on the mechanism’s requirements.

For instance, if calibration produces dark readings near 200 and bright readings near 800, thresholds of 300 and 700 may be a reasonable starting point. These are examples only. Sensor placement, shadows, reflections, artificial lighting, enclosure materials, and resistor value determine the correct values.

Example Arduino control sketch

This example assumes a driver with two active-high direction inputs and a safe state when both are LOW. Change the pins, active states, and enable/standby handling for your driver. It also assumes internal end limits or an equivalent external protection system.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
const int LIGHT_PIN = A0;
const int EXTEND_PIN = 5;
const int RETRACT_PIN = 6;

const int DARK_THRESHOLD = 300;
const int BRIGHT_THRESHOLD = 700;
const unsigned long MAX_RUN_TIME = 15000UL;
const unsigned long DIRECTION_PAUSE = 300UL;

enum MotionState { STOPPED, EXTENDING, RETRACTING, FAULT };
MotionState state = STOPPED;
unsigned long motionStarted = 0;

int readAverageLight() {
  long total = 0;
  for (int i = 0; i < 8; i++) {
    total += analogRead(LIGHT_PIN);
    delay(5);
  }
  return total / 8;
}

void stopActuator() {
  digitalWrite(EXTEND_PIN, LOW);
  digitalWrite(RETRACT_PIN, LOW);
  if (state != FAULT) state = STOPPED;
}

void extendActuator() {
  if (state == RETRACTING) {
    stopActuator();
    delay(DIRECTION_PAUSE);
  }
  digitalWrite(RETRACT_PIN, LOW);
  digitalWrite(EXTEND_PIN, HIGH);
  if (state != EXTENDING) {
    motionStarted = millis();
    state = EXTENDING;
  }
}

void retractActuator() {
  if (state == EXTENDING) {
    stopActuator();
    delay(DIRECTION_PAUSE);
  }
  digitalWrite(EXTEND_PIN, LOW);
  digitalWrite(RETRACT_PIN, HIGH);
  if (state != RETRACTING) {
    motionStarted = millis();
    state = RETRACTING;
  }
}

void setup() {
  pinMode(EXTEND_PIN, OUTPUT);
  pinMode(RETRACT_PIN, OUTPUT);
  stopActuator();
  Serial.begin(115200);
}

void loop() {
  if (state == FAULT) {
    stopActuator();
    delay(100);
    return;
  }

  int light = readAverageLight();
  Serial.println(light);

  if ((state == EXTENDING || state == RETRACTING) &&
      millis() - motionStarted > MAX_RUN_TIME) {
    digitalWrite(EXTEND_PIN, LOW);
    digitalWrite(RETRACT_PIN, LOW);
    state = FAULT;
    Serial.println("FAULT: actuator runtime exceeded");
    return;
  }

  if (light < DARK_THRESHOLD) {
    extendActuator();
  } else if (light > BRIGHT_THRESHOLD) {
    retractActuator();
  }
  // In the hysteresis band, keep the current command.

  delay(100);
}

The timeout limits a stalled or disconnected system, but it is not a substitute for current protection, physical limits, or feedback. Set it longer than the slowest legitimate travel under the real load while still limiting a fault. A timed actuator is open-loop: travel time changes with load, supply voltage, temperature, and starting position.

Stabilize changing light

  • Hysteresis: Keep separate dark and bright thresholds.
  • Averaging: The example averages eight readings to reduce short-term noise.
  • Minimum dwell time: Require the light condition to remain stable for perhaps 5–30 seconds before starting. Choose the interval for the application rather than treating it as universal.
  • Direction interlock: Stop both outputs and pause briefly before reversing.

Clouds, shadows, reflections, headlights, artificial lighting, sensor noise, and someone briefly covering the sensor can all create false transitions.

Rank #4
RVMARINEPAT Linear Actuator 12V with Controller 6" 3000N/660lbs Stroke Electric Actuator 5mm/s Motion Actuator Heavy Duty with Reverse Polarity Switch Controller
  • 3000N Heavy Duty: The 12V linear actuator is equipped with a strong 3000N motor. With 5.9 inch (150mm) stroke length, 5 mm/s travel speed, this 12 volt actuator could enable much bigger thrust force tasks compared to other 3000N actuators
  • Low Noise: The electric actuator 12V is made of aluminum alloy material. The internal gear of the actuator motor is upgraded to high-strength engineering plastic worm gear with low noise (≤50dB sound), large self-locking force, and strong durability
  • Flexible Motion: The linear actuators kit comes with 3 position & momentary reverse polarity toggle switch, and push the switch to the"UP" or "DOWN", realizing the flexible retract & extend of the liner actuator. Furthermore, as the switch is released, the 12V linear actuator will be locked at your wanted position. Therefore, the motion control can be easily and safely implemented to meet your specific needs
  • Wide Application: The electric actuator could perform tasks much efficiently and safely compared to manual operation. All in all, this actuator 12V could widely applied to window opener, electric sofa, electric wheelchair, electric nursing bed, automatic door opener, industrial electric lifting system, etc
  • With Controller: The package of this electric actuator 12V will also includes a polarity reversing switch to meet special need. In addition, the switch will also be equiped with all necessary parts for use, such as mounting panel to adapt different hole size, waterproof cap to make it suitable for outdoor use, terminal connectors to make it convenient for connecting
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

End-of-travel and mechanical safety

Some actuator models include internal end-of-stroke limit switches, but verify that feature for the exact model. Internal limits protect the actuator at its own endpoints; they may not protect a shade, hatch, vent, hinge, frame, hand, or object from a collision or crushing force. Firgelli recommends external limits where the mechanism needs additional protection.

For a construction or outdoor installation, use:

  • A fuse or resettable overcurrent device near the actuator supply.
  • External limit switches when the safe stop points are not the actuator’s full stroke.
  • Guarding and pinch-point protection.
  • A physical emergency-stop or power disconnect where people can reach the mechanism.
  • A weather-rated actuator, protected enclosure, cable glands, and a sensor location that will not collect water.
  • A software timeout and, where practical, current or position monitoring.

After a reset or power interruption, the Arduino does not automatically know the actuator’s position. Avoid assuming a known starting position unless feedback, a homing procedure, or a safely defined end-stop routine provides that information.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Timed control versus feedback

Approach Advantages Limitations
Timed movement Low cost and simple for basic open/close operation Position varies with load, voltage, temperature, and starting position; jams may remain undetected
Position feedback Repeatable intermediate positions, better recovery, and motion-failure detection More wiring and software; feedback types require model-specific handling and calibration

Feedback may come from a potentiometer, Hall sensor, optical encoder, or external position sensor. Firgelli documents optical-feedback actuators and potentiometer-feedback models. An optical interface may require a pull-up resistor or INPUT_PULLUP; values such as 10 kΩ or 15 kΩ in one actuator family do not apply to an ordinary LDR.

One sensor versus solar tracking

One sensor is appropriate for a binary action such as opening in daylight and closing at night. It measures brightness, not the direction from which light arrives.

To track the sun, use at least two matched sensors separated by a divider:

Left sensor  → A0
Right sensor → A1
error = leftReading - rightReading

The controller then moves slowly when the difference exceeds a deadband. A useful tracker also needs sensor calibration, mechanical alignment, position limits, a timeout, and a control loop that does not hunt. This is a different control problem from bright/dark automation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshooting

The actuator does nothing

  • Check supply voltage, fuse, wiring, and whether the supply can provide startup current.
  • Check the driver’s standby or enable input.
  • Confirm the Arduino and driver share logic ground when required.
  • Check for active-low relay inputs or an active-low H-bridge interface.
  • Confirm the actuator has not reached an internal limit.
  • Verify that it is actually a two-wire DC motor type.

It moves in the wrong direction

Swap the motor wires or reverse the software’s extend/retract mapping. Do not infer polarity from wire colors.

Best Value
Knowtek ADC120-12V Actuator + Governor ESD5500E + Magnetic Pickup Sensor MPU 3034572 for Generator 1 Set Actuator ADC120-12
  • This sale include 1 piece ADC120 +1 piece ESD5500E+1 piece 3034572 (Please declare the Voltage of ADC120 when placing order, 12V or 24V.)
  • Actuator ADC120 + ESD5500E for ≤100KW Generator
  • ADC120 actuator is Small, low cost, low friction model
  • The Engine Speed Controller ESD5500E is rugged enough to be placed in a control cabinet or engine mounted enclosure with other dedicated control equipment.
  • Magnetic Pickup Sensor MPU 3034572 length 80mm(3.15 inch)

It chatters or repeatedly reverses

Add hysteresis, averaging, a minimum dwell time, and a direction-change stop interval. Increase the threshold gap if normal sensor variation crosses the thresholds.

The actuator stalls

Check the load, alignment, obstruction, actuator duty cycle, supply voltage under load, and driver thermal/current ratings. A driver’s advertised peak current is not automatically its safe continuous rating.

The Arduino resets when motion starts

Look for supply voltage sag, shared-supply noise, poor grounding, inadequate power capacity, inductive interference, and missing driver protection. Use a properly rated separate actuator supply, short high-current wiring, appropriate fusing, and the protection specified by the driver manufacturer.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

The light readings are backwards or erratic

Print the readings, inspect the divider order and connections, and calibrate in the installed environment. Sensor orientation, wiring, shadows, reflections, and supply noise can all change the result.

It moves again after restarting

The controller may have lost its position state. If the actuator must resume safely after a reset, add feedback, a homing strategy, external limits, or a deliberate startup mode that requires a safe condition before motion.

Safer upgrades

For an occasional educational project, a two-wire actuator, calibrated LDR, and correctly rated driver may be sufficient. For an unattended construction or outdoor mechanism, a matched actuator-and-controller system is the better choice. Add feedback when intermediate positioning matters, current sensing when jam detection matters, and a manual override or emergency disconnect whenever people can access the moving assembly.

If you choose an Arduino board, the UNO R4 Minima is suitable for local sensor logic; the UNO R4 WiFi is more appropriate if remote monitoring or fault notifications are needed. Prices and availability vary by region and date. Also check library compatibility: Arduino notes that libraries relying on AVR-specific instructions may require changes on the UNO R4 Minima.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

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

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Site Office

Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.