thanks bro but what i mean is, the return to 0 is not dependent when the ldr showing more than half of light. what i want is when the ldr showing less than half of light the servo turns to 90 then automatically back to 0. in every reading that shows less than of light the servo turns to 90 then automatically back to 0. can you help me plsss
so if I understood you want the servo to move 0->90->0 when the target LDR level is detected.
if you are using a servo without feedback then probably the easiest way is to use a 'tuned' delay ie:
myservo.write(90); //move to 90 deg position
delay(x); //x milliseconds delay
myservo.write(0); //return to 0 deg position
if you are using a servo with feedback like this one then the other way of doing it is to keep reading the feedback (analogRead) within 'loop' and one it reach the 90deg position, run the "myservo.write(0); " to return the servo to zero position.