Arduino-Based Solar Tracker Using LDR Modules
Introduction
A solar tracker is a system that automatically rotates a solar panel toward the direction of maximum
sunlight, increasing the amount of solar energy captured throughout the day. In this project, two LDR
(Light Dependent Resistor) modules detect the intensity of light from opposite sides. An Arduino Uno
compares the sensor readings and controls an SG90 servo motor to rotate the solar panel until both
sensors receive nearly equal light.
Unlike traditional designs that use bare LDRs and resistors, this project uses LDR sensor modules,
eliminating the need for soldering and making the circuit simpler and more reliable.
Components Required
• Arduino Uno
• 2 × LDR Sensor Modules (Analog Output)
• SG90 Micro Servo Motor
• Breadboard
• Jumper Wires
• Mini Solar Panel (optional, for demonstration)
• Cardboard/Plastic Divider (between the LDR modules)
Circuit Connections
LDR Module 1 (Left)
Module Pin Arduino Pin
VCC 5V
GND GND
AO A0
LDR Module 2 (Right)
Module Pin Arduino Pin
VCC 5V
GND GND
1
Module Pin Arduino Pin
AO A1
Servo Motor
Servo Wire Arduino Pin
Red 5V
Brown/Black GND
Orange/Yellow Digital Pin 9
Note: Only use the AO (Analog Output) pin of each LDR module. Do not use the DO (Digital
Output) pin.
Working Principle
1. The two LDR modules continuously measure the intensity of sunlight.
2. The Arduino reads the analog outputs from both sensors.
3. If one sensor receives more light than the other, the Arduino rotates the servo motor by a small
angle toward the brighter side.
4. The process repeats until both sensors receive nearly equal light.
5. The attached solar panel remains aligned with the strongest light source.
A small divider placed between the LDR modules creates a shadow difference, enabling accurate tracking.
Arduino Code
#include <Servo.h>
Servo solarServo;
// ---------- Pin Definitions ----------
const byte LDR_LEFT = A0;
const byte LDR_RIGHT = A1;
const byte SERVO_PIN = 9;
// ---------- Servo Settings ----------
int servoPos = 90; // Start at center
const int SERVO_MIN = 10;
const int SERVO_MAX = 170;
2
// ---------- Tracker Settings ----------
const int TOLERANCE = 30; // Ignore small light differences
const int STEP = 1; // Move 1 degree at a time
const int SAMPLE_COUNT = 10; // Average 10 readings
// Read averaged LDR value
int readLDR(byte pin)
{
long sum = 0;
for (int i = 0; i < SAMPLE_COUNT; i++)
{
sum += analogRead(pin);
delay(2);
}
return sum / SAMPLE_COUNT;
}
void setup()
{
[Link](SERVO_PIN);
[Link](servoPos);
[Link](9600);
delay(1000);
}
void loop()
{
int leftValue = readLDR(LDR_LEFT);
int rightValue = readLDR(LDR_RIGHT);
int difference = leftValue - rightValue;
if (difference > TOLERANCE)
{
if (servoPos > SERVO_MIN)
{
servoPos--;
[Link](servoPos);
}
}
else if (difference < -TOLERANCE)
{
if (servoPos < SERVO_MAX)
{
3
servoPos++;
[Link](servoPos);
}
}
delay(40);
}
Advantages
• No soldering required
• Simple and low-cost design
• Smooth and stable servo movement
• Low power consumption
• Easy to build on a breadboard
• Can improve solar panel efficiency by continuously tracking the sun
Applications
• Solar power generation systems
• Solar-powered street lights
• Smart renewable energy projects
• Educational demonstrations
• Engineering and science exhibitions