## Introduction: Mr Tracker

Solar tracker provides 30% more electricity then normal Solar panel
• Hi Want to make your own Solar Tracker.
• Here are some easy steps by which you can make your own solar tracker.

Material Required.

• Aurdino Uno/Nano/Pro mini
• 9v battery
• 2 solar pannels (Any of size)
• 2 LDR (if you want to make 2 axis so you will required 4 LDR).
• Jumper wires
• Card board
• 1 Servo moter

## Step 2: How to Code.

If you not know about servo moter . Servo rotates only 180 degree. advantage of using servo is depend on us how much we want to rotate.

LDR , Resistance of LDR is low when its too much light and in dark it have very high resistance. We will put the code Inside If condition so we can easily rotate our solar panel using the resistance of ldr.

You can write your own code for this solar tracker . According to your solar tracker design.

Code of my solar tracker is:-

## Step 3: Code:-

```#include
Servo sg90;

int initial_position = 90;

int LDR1 = A0;          //connect The LDR1 on Pin A0```
`int LDR2 = A1;           //Connect The LDR2 on pin A1`
`int error = 5;         `
`int servopin=9;         //You can change servo just makesure its on arduino's PWM pin`
```void setup()
{```
```  sg90.attach(servopin);

pinMode(LDR1, INPUT);

pinMode(LDR2, INPUT);```
```
sg90.write(initial_position);```
```  //Move servo at 90 degree
delay(2000);

}
```
```void loop()
{```
```  int R1 = analogRead(LDR1); // read  LDR 1

int diff1= abs(R1 - R2);
int diff2= abs(R2 - R1);```
```
if((diff1 <= error) || (diff2 <= error)) {

}```
```else {
if(R1 > R2)```
```   {
if(initial_position>60)
{

initial_position = --initial_position;  ```
```    }
}

if(R1 < R2)

{```
```       if(initial_position<120)
{

initial_position = ++initial_position;
}
}

}

sg90.write(initial_position);

delay(50);```

}