the program is read top to bottom. when its reach's the last line it goes back to the top
so lets look at some of the code
minor point. don't use red words as variable names so
int press = 0; should be changed
to save having to write the pin high its better to use
pinMode(button, INPUT_PULLUP);
then you don't need
digitalWrite(5, HIGH); //enable pullups to make pin high
int servpos = 170;
int servpos1 = 80;
int pos = 80; //variable to store the servo position
int pos1 = 170; // variable to store the servo position
while (pos <= servpos && pos1 >= servpos1)
{ // in steps of 1 degree
pos++;
pos1--;
myservo.write(pos); // tell servo to go to position in
// variable 'pos'
myservo1.write(pos1); // tell servo to go to position in
delay(15); // waits 15ms for the servo to reach
// the position
}
when you leave this piece of code
168pos 82pos1
169pos 81pos1
170pos 80pos1 these are the last numbers written to the servos
2 seconds later (time it takes to flash redled 10 times) you tell the servos to move directly to
myservo.write(100);
myservo1.write(170);
so pos1 has to move from 80 to 170 and pos has to move from 170 to 100
that's going to be shown as a large fast movement
about 2 seconds after that
int pos = 80
int pos1 = 170
pos was 100 now it will be 80
pos1 was 170 and will stay 170
so only one wing will move
another problem is this code
if ((ledState1 == HIGH) && (currentMillis - previousMillis1 >= OnTime1))
{
ledState1 = LOW; // Turn it off
previousMillis1 = currentMillis; // Remember the time
digitalWrite(RedLed, ledState1); // Update the actual LED
}
else if ((ledState1 == LOW) && (currentMillis - previousMillis1 >= OffTime1))
{
ledState1 = HIGH; // turn it on
previousMillis1 = currentMillis; // Remember the time
digitalWrite(RedLed, ledState1); // Update the actual LED
}
if ((ledState2 == HIGH) && (currentMillis - previousMillis2 >= OnTime2))
{
ledState2 = LOW; // Turn it off
previousMillis2 = currentMillis; // Remember the time
digitalWrite(GreenLed, ledState2); // Update the actual LED
}
else if ((ledState2 == LOW) && (currentMillis - previousMillis2 >= OffTime2))
{
ledState2 = HIGH; // turn it on
previousMillis2 = currentMillis; // Remember the time
digitalWrite(GreenLed, ledState2); // Update the actual LED
}
this is in the open loop so it requires the program to leave this section and get back with in 250ms. With all the delays its not really doing anything. unless the button is high (not pushed) then all the delays are removed which will allow it to run correctly. Correction: you will still have this delay in there
delay(500); //delay for debounce
to be honest delay for debounce is not really needed unless the program is super fast and even then 40ms is about all that is required (fast to us but slow to a arduino)
(you might be seeing the red or green led being turned on and staying on which may seem random because of this section of code)
think about and test small programs to control your servos. You have the right idea to make small changes but you do that using a while where a if would be better that way the arduino can go check out the rest of the program and come back to make the next small change
(you will have to think about how you enter the number you want the servo to move to so its not rewritten every loop)