LOOP Termination

I Have interfaced a proximity sensor to servo. i want to make this servo sweep program to run only once when there is a change in proximity state, and wait for the rest of the time. Is this possible ? :confused:

Is this possible ?

Yes.

suryeah: I Have interfaced a proximity sensor to servo.

I expect you mean "I have interfaced a proximity sensor AND a servo to my Arduino UNO."

suryeah: i want to make this servo sweep program to run only once when there is a change in proximity state, and wait for the rest of the time. Is this possible ? :confused:

You want to use the sweeping code from the Servo Sweep example to perform a slow sweep of the servo when the proximity sensor changes state. Yes, that is easy.

Add code to loop() to read the proximity sensor and compare the new state to the previous state (saved in a global variable). If they are different, do the sweep. Save the new state as the previous state.