Robin2:
I suggest that you start with a program that only controls the motor (no EEPROM and no IR) to keep things as simple as possible until you figure out how to control the motor.I don't understand why you would have a function called setEncoderDirection(). In my mind you GET data from an encoder.
...R
beacuse Although I stopped the motor, the rotary encoder generates signal for a second after set pinout values LOW. The recieved signals must be processed.
So I have to remember the last command before STOP