Servo code invert trouble

Hello,

I am using the sweep code in from ardunio and I would like the servo to start from 180 Degrees and go to 90 Degrees. (It can't start at 0 Degrees because of the way my servo is mounted. Therefore it must start at 180 Degrees) I modified he sweep code (see code below) but when I run it, it doesn't work. It just goes to 180 Degrees and stays there.
How do I fix this?

Thanks.

This is the code:

/* Sweep
by BARRAGAN http://barraganstudio.com
This example code is in the public domain.

modified 8 Nov 2013
by Scott Fitzgerald

*/

#include <Servo.h>

Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards

int pos = 0; // variable to store the servo position

void setup() {
myservo.attach(10); // attaches the servo on pin 9 to the servo object
}

void loop() {
for (pos = 180; pos <= 90; 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 = 90; pos >= 180; 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
}
}

for (pos = 180; pos <= 90; pos += 1)

Think.

TheMemberFormerlyKnownAsAWOL:

for (pos = 180; pos <= 90; pos += 1)

Think.

Thought could be a useful concept.

What about

for (pos = 180; pos >= 90; pos -= 1)

...R

And the other one. If you start at 90 do you really think it will be greater than 180 even for the first loop?

Steve

Maybe to get the servo started off on the right foot, do something like the below in the code setup.

int pos = 90;    // variable to store the servo position

void setup() {
  myservo.attach(10);  // attaches the servo on pin 9 to the servo object
  myservo.write(pos);
}