Slowing down servos. How to write it into the program.

if (yellowState == HIGH)  
                                   
    for (int angle = 1; angle < 45; angle += 1) 
  myservo.write (angle);
  delay (100);

When I wrote the example in reply #3, I very carefully put in a set of { } braces.
They're important, and they're missing from your code.