Picture of Arduino Solar Tracker
What is does:
It searches for the brightest light source like the sun.

Remove these adsRemove these ads by Signing Up

Step 1: How it works

Picture of How it works
a boven.jpg
How it works:
I'd made a sensor of 4 LDRs with sheets between them

The withe stips are the LDRs 
When the stick on top is righted to the sun or the brightest point 
the four LDRs get the same amount of light on them.

Example1 when the light is left on top:
right-top, right-down, left-down are in the shadow
and left-top get the most light

Example2 when the light is on top
left and right down are in the shadow and top is in the light


Step 2: Parts List

  • 2 x servo's
  • 4 x lightdepending resistors (ldr)
  • 4 x resistors 10K
  • 1 x Arduino
  • 2 x potentiometers 10k (value doesn't matter)

Step 3: The set-up

Just hot glue it together!!! 

Step 4: The circuitry

Picture of The circuitry

Step 5: The Code

you can download the code down this page

/* this code is written by geobruce
for more info check my site http://xprobe.net
#include <Servo.h> // include Servo library 

Servo horizontal; // horizontal servo
int servoh = 90; // stand horizontal servo

Servo vertical; // vertical servo 
int servov = 90; // stand vertical servo

// LDR pin connections
// name = analogpin;
int ldrlt = 0; //LDR top left
int ldrrt = 1; //LDR top rigt
int ldrld = 2; //LDR down left
int ldrrd = 3; //ldr down rigt

void setup()
// servo connections
// name.attacht(pin);

void loop() 
  int lt = analogRead(ldrlt); // top left
  int rt = analogRead(ldrrt); // top right
  int ld = analogRead(ldrld); // down left
  int rd = analogRead(ldrrd); // down rigt

  int dtime = analogRead(4)/20; // read potentiometers
int tol = analogRead(5)/4;

int avt = (lt + rt) / 2; // average value top
int avd = (ld + rd) / 2; // average value down
int avl = (lt + ld) / 2; // average value left
int avr = (rt + rd) / 2; // average value right

int dvert = avt - avd; // check the diffirence of up and down
int dhoriz = avl - avr;// check the diffirence og left and rigt

if (-1*tol > dvert || dvert > tol) // check if the diffirence is in the tolerance else change vertical angle
if (avt > avd)
servov = ++servov;
if (servov > 180)
servov = 180;
else if (avt < avd)
servov= --servov;
if (servov < 0)
servov = 0;

if (-1*tol > dhoriz || dhoriz > tol) // check if the diffirence is in the tolerance else change horizontal angle
if (avl > avr)
servoh = --servoh;
if (servoh < 0)
servoh = 0;
else if (avl < avr)
servoh = ++servoh;
if (servoh > 180)
servoh = 180;
else if (avl == avr)
// nothing

1-40 of 233Next »
Spellmal made it!7 months ago

Just finished up my take on this tracker. I used continuous rotation servos, so i had to modify the code a bit. Super fun project, thanks geo Bruce!

AlberA Spellmal6 months ago

Hi could you send me the schematic for the build and the codes... because i think im going to go with the continuous rotation servos too.... ty

Spellmal AlberA6 months ago

My wiring and build was pretty much the same as GeoBruces, except for an LCD I added.

For your individual motors, the servohstop and servovstop values might need adjusting. If it doesnt work as is, try setting both of these values to 90 and go from there.

#include <LiquidCrystal.h> //include LCD Library

#include <Servo.h> // include Servo library

LiquidCrystal lcd (2, 3, 4, 5, 6, 7); //

Servo horizontal;

int servohStop = 95;

int servohLeft = 105; //move horizontal

int servohRight = 85;

Servo vertical; // vertical servo

int servovStop = 95;

int servovUp = 105 ;

int servovDown =87;// move vertical servo

// LDR pin connections

// name = analogpin;

int ldrLeftTop = 1; //LDR top left

int ldrRightTop = 0; //LDR top right

int ldrLeftBottom = 2; //LDR down left

int ldrRightBottom = 3; //ldr down right

int dtime = 25; //delay time in milliseconds

int tolerance = 100; //difference tolerance between ldr readings

int count = 0; //millis(); //start millisecond count

void setup()


lcd.begin(16, 2); //begin 16x2 LCD


// servo connections

// name.attach(pin);




void loop()


//int count = millis(); //start millisecond count

int leftTop = analogRead(ldrLeftTop); // top left

int rightTop = analogRead(ldrRightTop); // top right

int leftBottom = analogRead(ldrLeftBottom); // down left

int rightBottom = analogRead(ldrRightBottom); // down right

//print resistance values to serial monitor for debugging

Serial.println(leftTop );

Serial.println(rightTop );

Serial.println(leftBottom );

Serial.println(rightBottom );



int avt = (leftTop + rightTop) / 2; // average value top

int avd = (leftBottom + rightBottom) / 2; // average value down

int avl = (leftTop + leftBottom) / 2; // average value left

int avr = (rightTop + rightBottom) / 2; // average value right

int avgTot = (rightTop+rightBottom+leftTop+leftBottom) / 4;

int dvert = avt - avd; // check the diffirence of up and down

int dhoriz = avl - avr;// check the diffirence og left and right

if (count%10 == 1) //mod the millis count so the lcd screen updates every 10 millis


lcd.clear(); //clear the screen and position cursor at top left

lcd.print("dvert: "); //difference in vertical resistances read from the LDRs


lcd.setCursor(0,1); //set lcd cursor to bottom left

lcd.print("dhoriz: "); //difference in horizontal resistance read from the LDRs



if (-1*tolerance > dvert || dvert > tolerance) // check if the difference is in the tolerance else change vertical angle


if (avt > avd) //if average resistance on top is greater than on bottom




else //avg resistance on bottom is greater than on top





else if (-1*tolerance < dvert || dvert < tolerance) //if difference is smaller than tolerance, stop vertical servo




if (-1*tolerance > dhoriz || dhoriz > tolerance) // check if the difference is in the tolerance else change horizontal angle


if (avl > avr)









else if (-1*tolerance < dhoriz || dhoriz < tolerance) //if difference in horizontal






hendrif Spellmal3 months ago

can i know what is the function of the LCD?and can i get the full image of your model solat tracker?

I followed your schematic and used your code but I can't get info to display on LCD.. lcd back light lights up and white squares are there when I turn potentiometer... do the 4 resistors have to be a certain ohm to work correctly...
this is all I get :-(
AlberA Spellmal6 months ago

Thank you for the answers... so i wounder if your servos are modifyed to make a full spinn... if i do that to my servos would the code you sent me work?

Hi could you send me the schematic for the build and the codes... because i think im going to go with the continuous rotation servos toceers

AlberA Spellmal6 months ago

Hi could you send me the schematic for the build and the codes... because i think im going to go with the continuous rotation servos too.... ty

Hello is there any chance you could send me the schematic for the build and the codes... because i think im going to go with the continuous rotation servos too.... thank you

sali58 AlberA5 months ago

hi can you please send me same stuff (he schematic for the build and the codes for display ..)to build a solar tracker

Thank you

TomDunlap2 years ago
Just finished it and got it debugged. Really cool. Now I'm going to try to use it to build a Solar Forge and or a Solar Sand Sinter 3D Printer. Should be a snap. ;-)
geo bruce (author)  TomDunlap2 years ago
cool! :p
can you show us some video's or pictures?


*videos *thanks

Another development, I used a Makerbot Replicator to print a replacement for the foam core sensor holder. Here is the Sketchup pic of it. The two pieces glue together. The center top hole is for a fifth sensor to shut the system down if clouds block the sun so it doesn't try to point at the brightest cloud.
Pyramid 3.png
geo bruce (author)  TomDunlap2 years ago
nice upload your design to http://www.thingiverse.com/
geo bruce (author)  TomDunlap2 years ago
Sure, here is the link to the YouTube clip I made: http://youtu.be/6GTVWdeKvzY
geo bruce (author)  TomDunlap2 years ago

It's cool to see your instructable finished by someone else :D
it means i've helped someone ^^ or someone liked my project! :D
It's really helpful to get me started toward my other goals.
Next I want to modify the code to operate some 12V drill motors with a MotorShield or the like if I can find one that will handle the 3-4A current.
lheise1 month ago

i just dont know where to put the ldr`s, when i put in one way (LD in one side, RD in other side, etc), he works just one motor, sometimes just run of the sun, sometimes just works 2 ldr`s. Someone can help me??

mimax lheise1 month ago

I was so.:-(

hbulushios made it!2 months ago
thanx for the great project ..explain it in detail help me alot to finish it with excellent results
Can you help me please?? Email: lucas1_maluco@hotmail.com
please, i really need someone help
MamonJ1 month ago

what is the job of potentiometers ?

lheise MamonJ1 month ago
Speed and tolerance.
mirage120711 months ago

Hello :) i made this very cool solar tracker, implement a big solar cell and load wit it my cellphones! really really great!!!! big thank you!!

now i have a little question: is it possible to take one other LDR to shut down the servos at night? if its too dark, my tracker moves very wired.. :( so i think its a good idea to shut down at night... what did you think? :)

geo bruce (author)  mirage120711 months ago
good idea but you don't need an extra LDR for that just take the average of the 4 ldr's and If the value drops below a certain minValueShutDown then don't move the servos anymore
and when it's above a certain maxValueShutdown then let it start again

can you post some of your results (photo's videos)
Can you help me please?? I need to make one of these but it is not working, sometimes the ldr's follow a little, but most of the time they just move if a put my finger in one of them...
Can you help me?

@geo bruce. cool, so no need for more
hardware and electronics... could you progamm this? im a really bad
programmer in arduino... :( mine is more the hardware :)


caco.romeroh11 months ago

thanks! I'm trying to build it, this is my first stage

Ola, você fala portugues? Eu estou tentando fazer um desses mas eu ja montei e remontei 4 vezes mas n funciona, eu nao tenho idea do que fazer... voce pode me ajudar???

lheise1 month ago

Hey, can someone help me? i did everthing the same way that you, but mine is not working, the ldr`s does not follow the sun, can someone help me please??/


DonCesare1 month ago
Wow excellent ible!! I will use this in conjunction with my new hydroponics project and also a map of the sunlit parts of my backyard medicinal herbs garden! It will help me decide where to place specific plants!!! I have a few questions though. What are the model of the servos you used? If I use 6 mini solar panels to provide around 12v to power the servos, atmega328 and the pump for my hydroponics, 2 1kg of torque servos should be more than enough right?
Thank you in advance for the answers and for the great ible.
platypus52802 months ago

Hi, so i'm trying to run this with and LCD display. i followed Spellmal->AlberA 's instructions and i've gotten each part to work individually, but when i throw two servos an lcd and the ldr's on the board at the same time, nothing works. LCD display non-sence, servos vibrate. i've tried extra capacitors but got the same. any advice anyone?

FadhelA3 months ago

Hello geo bruce, am so interested in making this project, I need your help though, I ran to a trouble that I want this project to work on a normal DC motor and run it both ways, is there a way to do that ? or do i just have to stick with the Servo's.

The problem I have is that I have ordered 4 servo motor's to do the project and when it arrived i toke the motors and they were so small and it doesn't serve my design because i have modified the project to be a tracker for my solar system.

I really need your help if possible I will be so glad to hear your reply.

Thx again for sharing your idea.

Alcee3 months ago

why do you use 2 potentiometers??? which is their function?

wic13 months ago

Any idea how to use the same stuff on larger motor (to hold up home antena)?

Other thing is... how to do it so it will not wrap the cables around. Would be nice if it would go bac 'after the tracks' to the start after whole day round .

EVANNOH3 months ago

I'm using 60 degree's motor instead of 90 degree's motor what you used in. so how to change the coding?

1-40 of 233Next »