Thanks for your reply.
Actually, for 540 degrees of rotation of encoder in any one direction, my servo should rotate 30 degrees, in that direction. That's why i have used float.
But after your advice, I changed increment value to +1, instead of 0.5, still there's no improvement in output.
I did some more testing with code, and with use of Serial print i got some more information about the problem.
If my encoder is rotating in clockwise direction, motor will roate clockwise properly, now if i change the roation direction of encoder to Anticlockwise, then servo will not move at all, and it will start to rotate anticlockwise, after encoder had made 180 degrees rotation, in Anticlockwise direction, same for if encoder change direction from Anyiclockwise to clockwise. And the according to serial monitor, even though servo motor was not moving, it was receving servo.write instruction.
So i am really confused, if that has to do something with servo motor. But the same motor works just fine in "Sweep" code, given in Arduino example codes.
I even changed the servo motor, but the problem wasn still not solved.
Any ideas anyone, what i could be doing wrong?
Any help appericated. Thanks.
ABP