In this, we are going to discuss about Sun Tracking solar panel using Arduino. The main aim of this project is to provide maximum power Supply using solar panel. Here solar panel always follow the Sunlight that means face towards Sun to get charge all the time. In the Below Section, you will find the complete details like how it works and its constructional details.


  • Solar Panel
  • Arduino Uno
  • Servo motor
  • LDR-4
  • Resistors-4 (1kohm)
  • Battery 9v
  • Connecting wires


  • In this Arduino Solar Panel Tracker, Arduino is powered by the 5v adapter and the remaining parts will be powered by the Arduino.
  • The USB port is used to dump the source code.
  • Now getting into constructional details, first of all take getting a small piece of cardboard and cut it according to the Solar panel measurements.
  • Make four holes at the four corners of the cardboard and fix LDRs at each hole.
  • Connect one end of the LDR to one end of the resistor and also connect another end of the resistor to the Ao of the Arduino and connect the another end of that LDR to the ground.
  • Similarly, Second, third and forth fourth LDRs connect to the analog pins of A1, A2 and A3 pins of the Arduino.
  • These A0, A1, A2 & A3 are the Analog inputs. In the above section, LDR one end is connected to the resistor why because it any power fluctuation occurs, then LDR doesn’t damage due to the resistance which was connected to it.
  • Next connect the servo to the Arduino as per circuit diagram.


Servomotor:- It i used to rotate the solar panel in the direction of the Sunlight.

Arduino UNO:- It provides a low-cost and easy way for novice and professionals to create devices that interact with their environment.

LDR(Light dependent resistor):-It is also known photo resistors and work as a light detectors.

              ie, light sensing device

  • From the above, we can write two LDRs Are placed Oppositely to each other, Whenever the light falls LDR then its resistance will decrease that’s why it is regularly used in light or Dark detector circuit.
  • The servomotor has yellow wire which is used to control the rotation.
  • When the same amount of light Halls on the both LDR,then Servo motor will not Rotate that means both LDR have the same resistance.
  • If the Resistance of One LDR changes then the servo motor will try to move the solar panel toward the lower resistance LDR.


click here to DOWNLOAD

#include <Servo.h>//defining ServosServo servohori;int servoh = 0;int servohLimitHigh = 160;int servohLimitLow = 20;
Servo servoverti; int servov = 0; int servovLimitHigh = 160;int servovLimitLow = 20;//Assigning LDRsint ldrtopl = 2; //top left LDR greenint ldrtopr = 1; //top right LDR yellowint ldrbotl = 3; // bottom left LDR blueint ldrbotr = 0; // bottom right LDR orange
 void setup ()  {  servohori.attach(10);  servohori.write(0);  servoverti.attach(9);  servoverti.write(0);  delay(500); }
void loop(){  servoh =;  servov =;  //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
  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);}


Added by



Your email address will not be published. Required fields are marked *