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

  • LDR lead 1 – Ground
  • LDR lead 2 – 5V (via 10k resistor)
  • LDR lead 2 – Analog Pin 0

Relay Module to Arduino

  • VCC – 5V
  • GND – GND
  • IN1 – Pin 2
  • IN2 – Pin 3

Relay Module to Power Supply and Actuator

  • +12V to NC1 (normally closed terminal on relay one)
  • -12V to NO1 (normally open terminal on relay one)
  • NC1 to NC2
  • NO1 to NO2
  • COMMON1 to Actuator Lead 1
  • COMMON2 to Actuator Lead 2

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...

Read more »