You need to set the mode of the pin that the servo is attached to, to SERVO.
Servos don't use PWM, by the way.