But the direction of the motor should be different (if you're talking about the 2nd sample code). Could it be that with additional code lines somehow the chip isn't being completely erased before re-programming so the EEPROM variable is some number > 255?