Header Ads Widget

Making Solar tracker using Arduino

Making Solar tracker using Arduino :

hi, guys welcome to meworkstelugu in this article we know how to make a dual-axis solar tracker using Arduino. 
This solar tracker is moving both the x and y-axis using servo motors. this solar tracker is helpful in observing more sunlight from the sun because it moves in all directions regarding to the sun. now Let's talk about how to make this project. 

Components for Solar tracker using Arduino :

  • Arduino                          BuyNow
  • servo motors(2)              BuyNow
  • LDRs(4)                         BuyNow
  • 10k Resistors(4)            BuyNow
  • solar plate                      BuyNow
  • breadboard and wires    BuyNow
these are the major components to make this project.
If you want to buy Arduino components, I am giving you my affiliate links. If you buy the components using my affiliate links, it will help our channel and website growth. so do this small help.

making a video of a Solar tracker using Arduino :

to better understand making this project below video will help to you 




Making Solar tracker using Arduino circuit diagram:

connect all the components as shown below



Making Solar tracker using Arduino code:


#include <Servo.h>
//defining Servos
Servo servohori;
int servoh = 0;
int servohLimitHigh = 160;
int servohLimitLow = 20;

Servo servoverti; 
int servov = 0; 
int servovLimitHigh = 160;
int servovLimitLow = 20;
//Assigning LDRs
int ldrtopl = A2; //top left LDR green
int ldrtopr = A1; //top right LDR yellow
int ldrbotl = A3; // bottom left LDR blue
int ldrbotr = A0; // bottom right LDR orange

 void setup () 
 {
  servohori.attach(10);
  servohori.write(0);
  servoverti.attach(9);
  servoverti.write(0);
  Serial.begin(9600);
  delay(500);
 }

void loop()
{
  servoh = servohori.read();
  servov = servoverti.read();
  //capturing analog values of each LDR
  int topl = analogRead(ldrtopl);
  int topr = analogRead(ldrtopr);
  int botl = analogRead(ldrbotl);
  int botr = analogRead(ldrbotr);
  // calculating average
  int avgtop = (topl + topr) / 2; //average of top LDRs
  int avgbot = (botl + botr) / 2; //average of bottom LDRs
  int avgleft = (topl + botl) / 2; //average of left LDRs
  int avgright = (topr + botr) / 2; //average of right LDRs
   Serial.println(avgtop);
  if (avgtop < avgbot)
  {
    servoverti.write(servov +1);
    if (servov > servovLimitHigh) 
     { 
      servov = servovLimitHigh;
     }
    delay(10);
  }
  else if (avgbot < avgtop)
  {
    servoverti.write(servov -1);
    if (servov < servovLimitLow)
  {
    servov = servovLimitLow;
  }
    delay(10);
  }
  else 
  {
    servoverti.write(servov);
  }
  
  if (avgleft > avgright)
  {
    servohori.write(servoh +1);
    if (servoh > servohLimitHigh)
    {
    servoh = servohLimitHigh;
    }
    delay(10);
  }
  else if (avgright > avgleft)
  {
    servohori.write(servoh -1);
    if (servoh < servohLimitLow)
     {
     servoh = servohLimitLow;
     }
    delay(10);
  }
  else 
  {
    servohori.write(servoh);
  }
  delay(50);
}


If you have any doubts regarding this project, contact me on Instagram or comment on the YouTube video. I will help my best.

Post a Comment

0 Comments