Professional Documents
Culture Documents
h>
int westLDR = 0;
int error = 10; // Variable for is there is a noticable difference between the tow LDR's
int servoSet = 160; //Variable for position of servo - will be different for each device
void setup() {
Serial.begin(9600);
void loop() {
westLDR = analogRead(wLDRPin);
if (eastLDR < 400 && westLDR < 400) { //Check to see if there is low light on both LDR's
while (servoSet <=90 && servoSet >=15) { // if so, send panels back to east for the sunrise
servoSet ++;
servo.write(servoSet);
delay(100);
}
difference = eastLDR - westLDR ; //Check the difference
if (difference > 10) { //Send the panel towards the LDR with a higher reading
servoSet ++;
servo.write(servoSet);
servoSet --;
servo.write(servoSet);
Serial.print(" - "); //Use it to see if your LDR's are noticeably different when
Serial.print(westLDR); //They have equal light shining on them, if so, correct with the error value
Serial.print(" - ");
Serial.print(difference);
Serial.print(" - ");
Serial.print(" - ");
Serial.println(".");
delay(100);