Servo with LED...a project for a scale bridge.

I made a 6 foot model bridge. I have two servos, one running each half of the lifting part on the bridge. I also 4 LEDs, where one white led flashes like a strobe beacon, and the other red LED fades in an out, for each half of the bridge.

I want the bridge to slowly (much slower than the preset servo speed) go up and down with pauses of 1 minute at each the top and bottom of the bridge movement, and to have this recycle indefinitely. I also want the respective LEDs to constantly strobe and fade.

I’m pretty new to arduino, and can’t figure out how to get the lights to work WITH the servo cycling.

Regarding the servos, I have the Adafruit motor controller, but realized that I don’t need it if I’m just going to cycle the servos repeatedly. I have found the following code that might help slow down the servo, but I’m not sure how to integrate it into the code sample on the arduino playground. Could someone please help me with a sample code of how to combine the servo movement with the leds?

void loop() {
// cycle through every angle (rotate the servo 180 slowly)
for (myAngle=0; myAngle<=180; myAngle++) { 
servoPulse(servoPin, myAngle);
}
delay(1000);   
}

or

int refreshTime = 200; // ms the time in between pulses, servo speed adjustment

or

int speed = 2;//sets the speed of the servo range 0 – 5

Here is what I made so far, does anybody see any problems with it?

#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 
int pos = 0;    // variable to store the servo position 
int refreshTime = 200; // ms the time in between pulses, servo speed adjustment,be before the voids

 int ledPin13 =  13;    // LED connected to digital pin 13 BLINK
 int ledPin9 = 9;    // LED connected to digital pin 9 FADE
 // The setup() method runs once, when the sketch starts
 void setup()   {                
   // initialize the digital pin as an output:
   pinMode(ledPin13, OUTPUT);    
 myservo.attach(8);  // attaches the servo on pin 8 to the servo object  
 }

 // the loop() method runs over and over again,
 // as long as the Arduino has power
 void loop()                     
 {
   digitalWrite(ledPin13, HIGH);   // set the LED on
   delay(200);                  // wait for a second
   digitalWrite(ledPin13, LOW);    // set the LED off
   delay(1000);                  // wait for a second

// fade in from min to max in increments of 5 points:
   for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) { 
     // sets the value (range from 0 to 255):
     analogWrite(ledPin9, fadeValue);         
     // wait for 30 milliseconds to see the dimming effect    
     delay(30);                            
   } 
   // fade out from max to min in increments of 5 points:
   for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) { 
     // sets the value (range from 0 to 255):
     analogWrite(ledPin9, fadeValue);         
     // wait for 30 milliseconds to see the dimming effect    
     delay(30);          
 }

for(pos = 0; pos < 180; pos += 1)  // goes from 0 degrees to 180 degrees 
  {                                  // in steps of 1 degree 
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees 
  {                                
    myservo.write(pos);              // tell servo to go to position in variable 'pos' 
    delay(15);                       // waits 15ms for the servo to reach the position 
  } 


 }

Thanks so much for your help!
Steve

Updated

Some suggestions:

You want slow bridge movements with simultaneous led blinking, so delay() for long times is not good.

I would use some state variables (global variables):

char bridge_direction /* -1 going down, +1 going_up, 0 not moving /
int bridge_position /
servo value for bridge /
int bridge_start /
time in ms until next bridge movement starts, negative when moving */

unsigned long last_time /* Millisecond clock value last time loop() started /
unsigned long this_time /
Millisecond clock value this time loop() started */

Then I would write a function that calculates the current bridge position, give the above state variables. If the bridge is not moving, only bridge_start is updated by the elapsed time. When bridge_start becomes negative, start moving. If the bridge is moving, the position can be calculated from the time elapsed since beginning of movement and the direction. When the final position is reached, set bridge_start to 60000.

so in loop() you do:
save this_time to last_time
read new this_time from mills
calculate bridge_position
set servo value to bridge_position

There are no calls to delay() so you can do led blinkings