Bluetooth shield

Thanks for your help! In the mean time, I wrote the next code:

#include <Servo.h> 
 
Servo myservo;  // create servo object to control a servo 
 
void setup() 
{ 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
  Serial.begin(9600); //begins serial communication
} 
  
void loop() 
{ 
  int pos;
  if (Serial.available()){
    delay(100);
    while(Serial.available()>0){
      pos=Serial.read();     //reads the value sent from Visual Basic  
      if(pos=='0'){
      
  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 >= 0; 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
  } 
} 
    }
  } 
}

It works fine for me, however, it only makes 1 sweep. (so from 0 to 180 degrees and back) I want to make it an unlimited amount of sweeps. I think I made an error in the loops. Could someone help with that?

The second question is: I would like to make the angle of where it sweeps to adjustable. (so that I can change 180 to 40 degrees for example) I would like to do it on the Serial monitor. The other thing that I would like to change is the time of the delay. I would like to change that as well by giving a different input...

I really like your help by the way!!