Stepper Motor not moving accurately

palashrc0945:
If you look closely in my program, Serial.begin() is not called every time after receiving each character (it is outside the for loop).
and to answer your second query, i just wrote that pins 1 and 2 are used, but i am actually using 5 motors which are connected to I/O pins 3 through 12. So i don't think that should be a problem.

I disagree on both counts.

You ARE calling Serial.begin() after each received character. Look at lines 37, 64 etc.

You ARE using directionPin1 in the code that handles the 'f' and 'F' characters that you specified in your original post, and you ARE doing serial output in those cases which will cause the hardware Serial port to change the output state of the Tx pin (1). If you are using pin1 as a motor direction pin as implied by your code then this is wrong and will not work correctly, leading to exactly the sort of symptoms you have reported.

Also note that you only need to call pinMode() once per pin, so it is pointless (but harmless) to call this repeatedly within loop().