After that i can change the speed using the command
M1.writeMicroseconds(value);
But the problem is, each motor accepts different values. Like if I set both of them on 1300, they will have different speeds.
M1's minimum value is 1160 , M2's minimum is 1080.
So why is this difference and how to fix this?
ESC's can be calibrated. Look at the instructions for the ESC to find out how. For example, ESC's running the SimonK firmware use this process:
8. How to do throttle calibration
Disconnect the battery. Push your radio throttle to maximum,
connect the battery, wait for the 3 beeps (di da di), wait for 1s, you
will hear a short beep (di). Then immediately lower the throttle to minimum.
You will then hear another unique 2 beeps (di di), indicating you are setting
the low value. If you hear a long beep, it means the low throttle set.
Disconnect the battery, throttle calibration is done. If you hear a short beep,
it means low throttle set failed. You need to do the calibration again.
You probably need a set of variables for each motor which you can adjust to get values that give the same RPM. I certainly would not expect the same number to give the exact same RPM. There will be some variations in the ESCs and more variation in the motors.