Hi,
I am reading your code and I cannot understand a lot of things... In particular I cannot understand how you manage the two motors. If I'm not wrong you are using a shift register which is sending the HIGH/LOW levels to the A4988 drivers.
I suppose the 74HC595 shift register is connected to two A4988 drivers, but I cannot understand how the things are connected. I am referring to the following:

#define MOTOR1_A 2
#define MOTOR1_B 3
#define MOTOR2_A 1
#define MOTOR2_B 4
#define MOTOR3_A 5 // TERAZ ENABLE A4988
#define MOTOR3_B 7 // MS
#define MOTOR4_A 0 // MS
#define MOTOR4_B 6 // MS

// Arduino pins for the PWM signals.
#define MOTOR1_PWM 11
#define MOTOR2_PWM 3
#define MOTOR3_PWM 5
#define MOTOR4_PWM 6
The MOTORn_A and MOTORn_B are the output pins of the shift register but I cannot understand to which A4988 inputs are connected to. Which pin is connected to the RA motor? And which one to the DEC motor? I suppose you connected per each driver at least the `EN, MS1, MS2, MS3, STEP` and `DIR` inputs. Can you please help me?

Thank you.

Read More...