Servo stops when enter 0

Hello,

I have a project where I need to control a servo motor. The one I have is Futaba S3003. I want the servo to keep rotating until I enter 0 in the serial monitor. Is it possible? I thought of interrupts but the interrupts in arduino must be attachable and I want to avoid that. I am using Arduino Uno R3.

Here is my code:

#include <Servo.h>

Servo myservo;  // create servo object to control a servo
// twelve servo objects can be created on most boards
int state;
int pos = 0;    // variable to store the servo position

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

void loop()
{
  if (Serial.available () > 0)
  {
    state = Serial.read ();
    if (state == '1')
    {
      for (pos = 0; pos <= 180; pos += 1)
      {
        myservo.write(pos);              // tell servo to go to position in variable 'pos'
        delay(15);
      }
      for (pos = 180; pos >= 0; pos -= 1)
      {
        myservo.write(pos);              // tell servo to go to position in variable 'pos'
        delay(15);      // waits 15ms for the servo to reach the position
      }
      if (Serial.available () > 0)
      {
        state = Serial.read ();
        if (state == '0')
        {
          myservo.write ('90');
          delay (300);
        }
      }
    }
  }
}

In this code, the motor rotate once fully and then stops. I want it rotate fully all time until I enter 0

Can someone help?

Thanks to stackexchange, I found the solution:

New code:

#include <Servo.h>

Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
int state;
int pos = 0; // variable to store the servo position

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

void loop()
{
if (Serial.available () > 0)
{
state = Serial.read ();
if (state == ‘1’)
{
for (pos = 0; pos <= 180; pos += 1)
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15);
}
for (pos = 180; pos >= 0; pos -= 1)
{
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(15); // waits 15ms for the servo to reach the position
}
}
else if (state == ‘0’)
{
myservo.write (‘90’);
delay (15);
}
}
}

Stackexchange link: http://arduino.stackexchange.com/questions/9287/stop-servo-when-enter-0?noredirect=1#comment17707_9287