nclude // You might want this. Servo scanservo; Servo pointservo; int pos = 0; // variable to store the servo position int maxdeg = 180; // In the for loops below, this is the value that the servo trys to approach, this is the highest value int mindeg = 0; // Same as above, but it's the minimum value. int idelay = 5; //This is how long the servo has to write it's location int highnumber = 10000; //a random high number that is greater than any value the photocell can generate int highpoint; //an arbitrary declaration void setup() { pinMode(0, INPUT); Serial.begin(9600); scanservo.attach(9); // a servo's pwm wire @ 9 pointservo.attach(10); // a servo's pwm wire @ 10 } void loop(){ sweep(); // i'm running this inside a function because I've got other plans for it later. } int sweep(){ highnumber = 0; //sets the mumber the sensor has to be greater than to an even smaller number! for(pos = mindeg; pos < maxdeg; pos += 1){ //right to left Serial.print("The sensor reads : "); Serial.print(analogRead(0)); if (analogRead(0) > highnumber){ highnumber = analogRead(0); highpoint = pos; Serial.print(" The new highest value is : "); Serial.print(highnumber); Serial.print(" : At the position : "); Serial.println(highpoint); } else if (analogRead(0) <= highnumber){ Serial.print(" : The old highest value is : "); Serial.print(highnumber); Serial.print(" : At the position : "); Serial.println(highpoint); } scanservo.write(pos); delay(idelay); } for(pos = maxdeg; pos>=1; pos-=1){ //left to right Serial.print("The sensor reads : "); Serial.print(analogRead(0)); if (analogRead(0) > highnumber){ highnumber = analogRead(0); highpoint = pos; Serial.print(" The new highest value is : "); Serial.print(highnumber); Serial.print(" : At the position : "); Serial.print(highpoint); } else if (analogRead(0) <= highnumber){ Serial.print(" : The old highest value is : "); Serial.print(highnumber); Serial.print(" : At the position : "); Serial.println(highpoint); } scanservo.write(pos); delay(idelay); } pointservo.write(highpoint); //writes to the servo where the photocell saw the most resistance, thus the brightest point. }