Servo Paning Help

I’m trying to make my servo pan back and forth. It prints the number going up, but the servo doesn’t move.

I’m new to C programming, so any help would be appreciated.

Thanks.

My Code:

#include <Servo.h>

Servo servo1;

void setup()
{
servo1.attach(14);
// servo1.setMaximumPulse(2200);

Serial.begin(19200);
Serial.print(“Ready”);
}

void loop()
{
for(int v=0; v < 180; v++){
servo1.write(v);
Serial.print(“Servo 1:”);
Serial.print(’\t’);
Serial.print(v, DEC);
Serial.println();
}

Servo::refresh();
}

I found the problem, I needed to keep refreshing the servo.

I used the servotimer1 to fix it.

My fixed code:
#include <ServoTimer1.h>

ServoTimer1 servo1;
//ServoTimer1 servo2;

void setup()
{
pinMode(1,OUTPUT);
servo1.attach(9); //Digital pin 9
// servo2.attach(10); //Digital pin 10
Serial.begin(19200);
Serial.print(“Ready”);
}

void loop()
{
int d=220; //time for delay
int beg=0;
int mid1=60;
int mid2=120;
int end=180;

servo1.write(beg);
Serial.print(“Servo 1:”);
Serial.print(’\t’);
Serial.print(beg, DEC);
Serial.println();

delay(d);

servo1.write(mid1);
Serial.print(“Servo 1:”);
Serial.print(’\t’);
Serial.print(mid1, DEC);
Serial.println();

delay(d);

servo1.write(mid2);
Serial.print(“Servo 1:”);
Serial.print(’\t’);
Serial.print(mid2, DEC);
Serial.println();

delay(d);

servo1.write(end);
Serial.print(“Servo 1:”);
Serial.print(’\t’);
Serial.print(end, DEC);
Serial.println();

delay(d);

servo1.write(mid2);
Serial.print(“Servo 1:”);
Serial.print(’\t’);
Serial.print(mid2, DEC);
Serial.println();

delay(d);

servo1.write(mid1);
Serial.print(“Servo 1:”);
Serial.print(’\t’);
Serial.print(mid1, DEC);
Serial.println();

delay(d);

}