Newb, servo easing, need help

Hello
I'm building a robot using mainly DC motors, H Bridge controllers, controlled with Arduino Uno's. I managed to Fumble through writing sketches for all those but here's where the problem lies.
I'm using 1 Servo motor to control my head movement left and right and center. The servo moves to each position at full speed. I need the movements to ramp up and ramp down to each position. Is there a way to add this to my basic sketch below?
Please be kind any help would be greatly appreciated thank you.

#include <Servo.h>
Servo servoMain; // Define our Servo
void setup()
{
servoMain.attach(10); // servo on digital pin 10
}
void loop()
{
servoMain.write(90); // Turn Servo Left to 45 degrees
delay(5000); // Wait 1 second
servoMain.write(40); // Turn Servo Left to 0 degrees
delay(3000); // Wait 1 second
servoMain.write(90); // Turn Servo back to center position (90 degrees)
delay(5000); // Wait 1 second
servoMain.write(140); // Turn Servo Right to 135 degrees
delay(1000); // Wait 1 second
servoMain.write(90); // Turn Servo Right to 180 degrees
delay(5000); // Wait 1 second
servoMain.write(40); // Turn Servo back to center position (90 degrees)
delay(3000); // Wait 1 second
servoMain.write(140); // Turn Servo Right to 135 degrees
delay(1000); // Wait 1 second
servoMain.write(90); // Turn Servo Right to 180 degrees
delay(5000); // Wait 1 second
servoMain.write(40); // Turn Servo back to center position (90 degrees)
delay(3000); 
}

Is there a way to add this to my basic sketch below?

Move the servo a little each time through loop() instead of to the extremes. To do this efficiently you should use millis() for timing rather than delay().

Move the servo a little and save the value of millis() at that time
Each time through loop() check whether millis() - start time is greater than say 50 milliseconds
If no then just go round loop() again
If yes then move the servo a little and save the time
Keep going until the servo has reached its target position.

See Several things at the same time for examples

Or instead of Servo.h use the VarSpeedServo.h library that does it all for you. You don't learn as much but you do get the program working with less effort.

Steve

Thanks.
Ill download library
And see if it will work for me.

Thanks.
Ill download library
And see if it will work for me.