LED not fading

here is my script the lights have more of a blink affect they dont fade. can anyone tell me what i did wrong?

#include <Servo.h>

Servo myservo;

int ledPin = 13;

void setup()
{
myservo.attach(9);
}

void loop() {
for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=5) {
analogWrite(ledPin, fadeValue);
delay(51);
}

for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=5) {
// sets the value (range from 0 to 255):
analogWrite(ledPin, fadeValue);
delay(51);
}
myservo.write(1500);
}

1st off...in order to use analogWrite() you must use a PWM pin. You're using pin 13 which ISN'T. If your board is like mine it should be pins 3,5,6,9,10,11 (it should say so on the board itself).

2nd...you shouldn't write myservo.write(1500). You're supposed to write an angle between 0 and 180 degrees. NOT 1500 degrees!!

its a continuous servo. I was told to write that by a friend, but wouldnt doubt if he was wrong. Does this make a difference.

Well your fading problem is due to the PWM issue I mentioned. The servo issue shouldn't affect that. And I'm not sure what will happen when you write 1500 degrees to a servo? Perhaps the servo wont move, perhaps it will just be interpretted as the max position (=180 degrees) or perhaps it would damage the servo (which is why I haven't tried it). Either way there is no point to it.

Perhaps your friend meant you should write myservo.writeMicroseconds(1500), which is another way of controlling servos. But myservo.write(1500) seems rather pointless...

Thank you it all works now

you shouldn't write myservo.write(1500). You're supposed to write an angle between 0 and 180 degrees.

yes and no, I hope the following clarifies the use of microseconds with the servo library:

The documented method uses degrees for myservo.write but a writeMicroseconds method is supported by the library although it is not part of the official Arduino language.

The myservo method handles out of range values by treating all values greater than 544 as microseconds – so valid values in microseconds passed to write will do exactly the same thing as calling writeMicroseconds. if you want to work in microseconds, using the writeMicroseconds call makes your intentions clearer than passing microseconds to the write method