smoothing servo movements

I have a bot that works well. it uses an ultrasonic proximity detector that pans 180 degrees. two "bumper" switches. it is driven by two continuously rotating servos "skid steer". I would like to smooth out the start/stop speed of the servos that drive it. they start and reverse directions too rapidly, and I am worried this will eventually damage them.

ping_pan_roam_switch.ino (4.6 KB)

const int RForward = 47; //speed value of drive servo, value 0 for full speed rotation
const int RBackward = 180; //speed value of drive servo, value 180 for full speed
const int LForward = RBackward; //servos rotate opposite directions to drive in same
const int LBackward = RForward; //servos rotate opposite directions to drive in same

The problem is, you always use one speed, essentially the maximum. Try using
graded values instead of "constants", and start off with speed = 0 [pw = 90].

int LForward = 90; //servos rotate opposite directions to drive in same direction
int LBackward = 90; //servos rotate opposite directions to drive in same direction

thank you, I did a little rearranging. removed the const and rightbacward=leftforward and vise versa. I dont understand "graded". but I feel like I am several steps closer to the effect I wanted to get. will have to do some reading. here is code now.

ping_pan_roam_switch.ino (4.54 KB)

Graded just means use different pulsewidth values over the entire range, 0..180,
and not just the max endpoint values. And make smallish changes to servo speeds
rather than huge changes. Eg, you can build up speeds from 0 to max by stepping
0, 25%, 50%, 75%, 100% over a couple of seconds.

I am at a loss on how to modify my code to smooth the drive servos start/stop/reverse movements. I have tried to include parts of the sweep code example from the servo library into my code. for(pos = 0; pos < 180; pos += 1) for(pos = 180; pos>=1; pos-=1)
nothing I have tried compiles.
I have attached my code. I am looking for help figuring out what and where to add to this code that would achieve this effect.

ping_pan_roam_switch.ino (4.54 KB)

Add two variables per motor. One to represent the speed it has now, the second to be desired speed. Where you set the motor speed now, just set desired speed instead. At the top of loop, check to see whether there is a difference between actual and desired speed. If so, increment or decrement actual as appropriate to get it closer to desired. Put in a small delay here too. If the speeds all match up, use your existing code for navigation.