Components required
1. Arduino Uno 1
2. LDR 2
3. 1K Resistor 2
4. Servomotor 1
5. Jumper wire Few
6. Small Solar panel 6V
Circuit diagram -
Program for Arduino Uno -
//BigEdx youtube chanel.
//Rajeev kashyap
//Add servo library
#include <Servo.h>
#define LDR1 A1
#define LDR2 A2
#define error 10
//Home position of the servo motor
int Home = 90;
Servo myservo;
void setup() {
myservo.attach(9);
//Set the Home position of servomotor
myservo.write(Home);
delay(250);
}
void loop() {
//for LDR1 sensor value
int ldr1 = analogRead(LDR1);
//for LDR2 sensor value
int ldr2 = analogRead(LDR2);
//comparision of both LDR values
int value1 = abs(ldr1 - ldr2);
int value2 = abs(ldr2 - ldr1);
if ((value1 <= error) || (value2 <= error)) {
} else {
if (ldr1 > ldr2) {
Home = --Home;
}
if (ldr1 < ldr2) {
Home = ++Home;
}
}
myservo.write(Home);
delay(80);
}
/*Solar tracker
https://Bigedx.blogspot.com
*/