I'm very new to arduino related stuff so this question might be really easy to answer. I don't understand how multiple PWM outputs are supposed to work. Look at the pic. enter image description here
In the first(1) case we are using short signal width which would be close to motor staying still. In this case, as can be seen, short pulses follow each other, so does the code.
motor1.writeMicroseconds(shortWidth);
motor2.writeMicroseconds(shortWidth);
motor3.writeMicroseconds(shortWidth);
motor4.writeMicroseconds(shortWidth);
when motor4 ended it's output, motor1 starts it's pulse again causing non-problem consequent pulses.
In the second(2) case pulse is wider which corresponds to setting motor speed close to maximum. After motor1 finishes generating width, it's time for motor2 to generate one. But when it does, motor1's period comes to end and it has to start generate width again, but arduino is busy generating pulse of motor2.
How does PWMs work in this case?
writeMicroseconds
calls don't directly relate to any change in the output state of a pin. They just reconfigure the servo lib's signal generator that uses interrupts to change the pin when a certain amount of time has passed.