Arduino Video Code Mc
Arduino Video Code Mc
Servo myservo;
#define ldr1 A0 // set ldr 1 Analog input pin of East ldr as an integer
#define ldr2 A1 // set ldr 2 Analog input pin of West ldr as an integer
int pos = 90; // initial position of the Horizontal movement controlling servo
motor
int tolerance = 20; // allowable tolerance setting - so solar servo motor isn't
constantly in motion
void setup(){
delay(1000); // 1 second delay to allow the solar panel to move to its staring
position before comencing solar tracking
void loop(){
//no servo motor horizontal movement will take place if the ldr value is within
the allowable tolerance
}else {
if(pos > 180) {pos = 180;} // reset the horizontal postion of the motor to 180
if it tries to move past this point
if(pos < 0) {pos = 0;} // reset the horizontal position of the motor to 0 if it
tries to move past this point
delay(50);