Synchronize two DC motors rotation in opposite directions by Arduino Due

Hello,

I am trying to synchronize the rotation of two DC motors with encoder that will rotate in opposite directions and are controlled by Arduino Due micro-controller. After completing certain numbers of rotation the the DC motors will stop and after a short delay, they will rotate in reverse directions and complete same numbers of rotation. I am looking for a code that might help me to do so. Also, Do I need two separate Arduino due micro-controllers for two DC motors or one will be enough?

Thanks,
Shahrior

Definitely need just one microcontroller! You are simply driving two motion control systems in tandem, just
need to duplicate the control loop variables per motor.