At Progressive Automations, we offer many options for controlling your linear actuator. From simple solutions like rocker switches, to our more advanced controllers such as the PA-35 Wi-Fi Control Box, we have many plug-and-play choices. However, sometimes project requirements and customer needs are a little more unique than what these options can offer. This is where microcontrollers can really be our friends. In this article, we will be going over how we can change the position of an actuator based on the amount of light that is present, giving you a unique and advanced form of linear actuator control.


All we need for this project is an Arduino (in this case an Arduino Uno), a light-dependent resistor (also known as a photoresistor or LDR), one 10k ohm resistor, a 2-channel relay module and, of course, an actuator.

Check out our Arduino Uno, which was critical for this project!



In many cases, we will be using this type of trigger for outdoor applications such as a solar powered chicken coop door actuator. You need to be considerate of what kind of environment your actuator will be operating in, and make sure your actuator has the correct IP rating. To help with this, you can find our IP rating guide here. We also need to make sure you find the right stroke length and force rating for your actuator. For help with this, you can refer to one of our many other blog posts here. In essence, the type of actuator you use is totally dependent on your application and the harshness of the environment you are in.


The wiring for this solar-powered actuator

The wiring for this solar powered actuator project is as follows:

LDR to Arduino

Relay Module to Arduino

Relay Module to Power Supply and Actuator

Using a 2-channel relay module, the above instructions are how you wire this project. This is a very simple setup that is easy to code, but it does have its limitations. If you want to add features such as speed control or force feedback, you may want to consider using the MegaMoto motor driver shield instead.  More info on that here.


The functionality of the provided code is meant to be as simple as possible. When there is light, the actuator will retract. When it is dark, the actuator will extend. To prevent the actuator from being triggered unintentionally, (if someone walks by and blocks the light, or if a flash of lighting is picked up by the sensor) the change from dark to light (or light to dark) must last at least thirty seconds. This delay can easily be changed by changing the value of “const int triggerDelay”.

The amount of light present is determined by reading the voltage going to analog pin 0. The more light there is, the less resistance our light dependent resistor will have. Since we are using a pullup resistor, this will mean the voltage will go down as the environment gets brighter. The Arduino reads this as a value between 0 and 1028. If you want to change the value at which the state of the actuator will change, simply change the value of “const int threshold” (set to 650 by default).

This code will serve its purpose as is, but the great thing about projects like these is that there is always room for improvement. Feel free to modify this code to better suit your solar powered linear actuator application! A few examples of extra functions that could be added to this code are: a timeout to prevent the actuator from continuing to travel if it does not hit the limit switch within a certain period of time; collision detection via current draw monitoring (would require a MegaMoto driver instead of relays); or a function that would allow the actuator to be set to various positions based on the amount of light (not just all the way up or all the way down).

Outdoor applications benefit from this type of trigger. Check out the highly-protected actuators we carry!


 /*The hardware required for this project is an Arduino, one light dependant resistor (LDR), a 10K resistor and a 2-channel 5V relay module. Its purpose is to control the extension and retraction of an actuator based on the amount of light that is present.  Written by Progressive Automations 12/02/2020

#define relay1 2 //relay used to extend actuator
#define relay2 3 //relay used to retract actuator
int ldr; //analog reading from light dependent resistor int countOpen = 0;//counts how long sensor is recieving light
int countClose = 0;//counts how long the sensor is not recieving light
const int triggerDelay = 3000;//number of seconds x 100 to wait after lighting changes before triggering actuator const int threshold = 650;//
void setup() {

void loop() {

void checkSensor()
ldr = analogRead(0);
if(ldr > threshold)//if reading is greater than threshold, start counting
{  countOpen++;//count how long the sensor is not recieving light  delay(10);
{  countOpen = 0;//reset count to zero if statement is not true
if(countOpen > triggerDelay)// wait x seconds before triggering actuator {  extend();//extend actuator

if(ldr < threshold)//if reading is less than threshold, start counting
{  countClose++;//count how long sensor is recieving light  delay(10);
{  countClose = 0;
if(countClose > triggerDelay)// wait x seconds before triggering actuator {  retract();


void extend()
{  digitalWrite(relay1,LOW);  digitalWrite(relay2,HIGH);

void retract()
{  digitalWrite(relay2,LOW);  digitalWrite(relay1,HIGH);


So, there you have it! Our methodology behind using a linear actuator light sensor to control your actuator using solar power. We know that not every application is the same, so you may have some queries about this project, or some alterations you want to run by our team of engineers. That is no problem – just send us an email through, or call us toll-free at 1-800-676-6123.