Introduction: Arduino Solar Tracker
What is does:
It searches for the brightest light source like the sun.
There is a newer and better version of this project: https://www.instructables.com/id/Dual-Axis-300W-IOT-Solar-Tracker/
Step 1: How It Works
I'd made a sensor of 4 LDRs with sheets between them
The white dots are the LDRs
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 Ebay link 1.5$ / piece
- 4 x lightdepending resistors (ldr) Cheap LDR's on Ebay 0.78$ for 20 pcs
- 4 x resistors 10K Resistors on Ebay 0.78$ for 50pcs free shipping
- 1 x Arduino Arduino UNO Ebay link 3.5$ free shipping
- 2 x potentiometers 10k (value doesn't matter) Ebay link
Step 3: The Set-up
Just hot glue it together!!!
Step 4: 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()
{
Serial.begin(9600);
// servo connections
// name.attacht(pin);
horizontal.attach(9);
vertical.attach(10);
}
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;
}
}
vertical.write(servov);
}
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
}
horizontal.write(servoh);
}
delay(dtime);
}
Attachments

Runner Up in the
Celestron Space Challenge

Participated in the
Microcontroller Contest

Participated in the
Make It Move Challenge
20 People Made This Project!
- viktor1234567890ty made it!
- brutoncs made it!
- Electron0101 made it!
- AymanH21 made it!
- נדבא made it!
- YeganeA made it!
- tatoo23 made it!
- tatoo23 made it!
- yacinehooo made it!
See 11 More
295 Comments
9 years ago on Introduction
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. ;-)
Reply 7 years ago
Hey Tom, We are right now making a Solar sand sinter 3D printer. We have finished making the coordinate plate and are working on the tracking system now. Would like to get your inputs. Best,
Reply 7 years ago
hi dude ,
what is the rate and power of servo motor which u have used.. can u give me some details.. i have to do this as mini project
Reply 7 years ago
Good luck with your project. I have not been able to pursue this one so not much more to add. Everything you need should be available online now. Except time and money. You'll have to come up with those. ;-)
Reply 9 years ago on Introduction
cool! :p
can you show us some video's or pictures?
thnx
Reply 9 years ago on Introduction
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.
Reply 9 years ago on Introduction
nice upload your design to http://www.thingiverse.com/
Reply 9 years ago on Introduction
OK, Here it is. Heliostat Solar Sensor support structure
Reply 9 years ago on Introduction
thnx!!
Reply 7 years ago
What are the results and conclusions
Reply 7 years ago
What are the results and conclusions
Reply 8 years ago on Introduction
*videos *thanks
Reply 9 years ago on Introduction
Reply 9 years ago on Introduction
Nice!!!
It's cool to see your instructable finished by someone else :D
it means i've helped someone ^^ or someone liked my project! :D
Reply 9 years ago on Introduction
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.
2 years ago
This is the code that has really worked for me. I just had to change the ldr pins to suit my design because I have already done the hardware some days back.
I really appreciate your good works.
2 years ago
Hi, thank you very much for the idea. I adapt it for 2 LDR:
// (*) según el montaje se puede modificar
// (*) must be modified according to the assembly
#include // include la libreria Servo.h
Servo horizontal; // se nombra el servo horizontal
int LDRl = 1; // pin de la fotoresistencia left
int LDRr = 2; // pin de la fotoresistencia right
int delayPot = 4; // pin del potenciometro 10k para la velocidad
int tolPot = 5; // pin del potenciometro 10k tolerancia
int paso = 2; // estos son los grados de cada movimiento(1, 2 or 5) (*)
int servoh = 90; // initial position
void setup()
{
Serial.begin(9600);
horizontal.attach(9); // se define el pin del servo
horizontal.write(servoh);
delay(1000);
horizontal.write(0); // this line helps to a inicial test
delay(1000); // this line helps to a inicial test
horizontal.write(180); // this line helps to a inicial test
delay(1000); // this line helps to a inicial test
horizontal.write(servoh); // this line helps to a inicial test
delay(250); // this line helps to a inicial test
}
void loop()
{
int medidaLDRl = analogRead(LDRl); // medida LDR izquierdo (left)
int medidaLDRr = analogRead(LDRr); // medida LDR derecho (right)
int delaytime = analogRead(delayPot)/2 + 100; // potenciometro velocidad (*)
int tol = (analogRead(tolPot)+10) / 10 + 10; // potenciometro tolerancia (*)
int diffhoriz = medidaLDRl - medidaLDRr; // calcula la diferencia entre left and rigt
if (diffhoriz < -1*tol || diffhoriz > tol) // check if the difference is in the tolerance else change horizontal angle
{
if (medidaLDRl > medidaLDRr)
{
servoh = servoh - paso;
if (servoh < 0)
{
servoh = 0;
}
}
else if (medidaLDRl < medidaLDRr)
{
servoh = servoh + paso;
if (servoh > 180)
{
servoh = 180;
}
}
else if (medidaLDRl == medidaLDRr)
{
// nothing
}
horizontal.write(servoh);
}
delay(delaytime);
}
3 years ago
Nice Explanation Engineer!
I’ve also created a solar Tracker which is operated without Arduino.
It consists of only this components –
LDR Module
L293D Motor Driver Module
DC Motor 30 RPM
Solar Panel (Any ratings)
Checkout the Full tutorial Here – http://alphaelectronz.com/solar-tracker-without-arduino/
Question 3 years ago
Hi I was wondering if I can use your code for my school project?
Question 3 years ago
Доброго времени! Вы сделали новый проект, и новый скетч, но не указали как подключить Н-мост. Купил 7A-160W. Как подключить старый скетч?