Arduino Solar Tracker with Two LDRs and a Servo
Level 42 · Sun Seeker · 35 minutes
A solar tracker: two light sensors steer a servo so the panel keeps facing the sun, all day.

Preview the project free; a course seat is required to run and submit. No hardware kit needed.
Your project challenge
Turn the solar panel to face the sun. Wire it up: - LDRs: east middle leg A0, west A1, outer legs 5V and GND - Servo: signal D9 - LCD: RS D12, E D11, D4-D7 to D5/D4/D3/D2 Start at 90. Every 20 ms, step 1 degree toward the brighter LDR. Within 50: hold. LCD (not graded): EAST, WEST or HOLD.
Components you’ll use
- Arduino Uno
- LDR (Light-Dependent Resistor) × 2
- SG90 Micro Servo
- LCD 16x2 Display
What you’ll build
A solar tracker: a panel that follows the sun all day.
How it works
- A panel makes the most power when it faces the sun square on.
- Two LDRs (light sensors) sit on the panel’s edges, with a small wall between them.
- Facing the sun, both get the same light. With the sun to one side, the wall shades one.
- The servo turns the panel:
0faces east,90is flat,180faces west. - The LCD shows
EAST,WESTorHOLD. It is for you: only the panel is checked.
The key idea
The panel never needs to know where the sun is. It only asks which side is brighter.
More than 50 apart: step 1 degree toward the brighter side, every 20 ms.
Closer than 50: hold. Hold means stay where you are. It does not mean go back to 90, fast or slow.
⚠ Watch out
Do not jump straight to 0 or 180. The checks look part-way through each turn, and a jump is already at the end.
A long Serial.print every pass slows the loop, so the panel turns too slowly. Print less.
The interactive editor includes the wiring guide, code editor and simulation controls.