I tried to control servo's rotation speed with a library called "VarSpeedServo.h". I set the speed at 50 and it worked out perfectly when I change for(int i= Min; i<=Max; i++) to for(int i= Min; i<=Max; i+=30) (same for j). Can someone tell me why?
i++ is the same as i+=1 and increments the value of i by one.
You have just changed the increment to 30, so all that should happen is that the servo runs faster.
How do i+=1 and i+=30 affect the speed of servo?
I faced an error (the servo moved very slowly) when I wrote i++ with my code, but It ran perfectly at speed of 50 when I changed to i+=30.
I tried to control servo's rotation speed with a library called "VarSpeedServo.h". I set the speed at 50 and it worked out perfectly when I change for(int i= Min; i<=Max; i+=1) to for(int i= Min; i<=Max; i+=30) (same for j).
How do i+=1 and i+=30 affect the speed of servo?
I faced an error (the servo's speed was not 50 and moved very slowly) when I wrote i++ in my code, but It ran perfectly at speed of 50 when I changed to i+=30.
Because the for loop completes its work quicker, so it gets to the end in fewer iterations of the loop.
Note, you should give a servo time to actually move, this is normally done using a delay. I can only assume that the VarSpeedServo.h library does this for you.
Cross-posting is against the Arduino forum rules. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend a lot of time investigating and writing a detailed answer on one topic, without knowing that someone else already did the same in the other topic.
Repeated cross-posting can result in a suspension from the forum.
In the future, please only create one topic for each distinct subject matter. This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.