connecting 5V servo to ultimaker 3d printer

Hi,
I am using an ultimaker original which is controlled by an arduino Mega and a ramps shield.

The controller usually controls stepper motors. However I want to control a 5V servo motor also (Model: SM-S2309s) via pin 13 on the shield using Repetier Host.
i.e I want to write gcode in Repetier to control the angle of the servo.

I have uncommented the code in the Marlin firmware and tried activating the servo motor via G-code commands: M340 P1 S500
but I haven't been able to succeed.

(Firmware:
#define NUM_SERVOS 1 // Servo index starts with 0 for M280 command)

There is power getting to the servo as I can here a small buzz when I upload the firmware, however I can't get it to move.

Any help would be appreciated.

JJBYRNE:
I have uncommented the code in the Marlin firmware and tried activating the servo motor via G-code commands: M340 P1 S500
but I haven't been able to succeed.

Which code ... No, don't answer that, Marlin is just too complicated.

You may get relevant advice on the RepRap Forum.

I don't know if there is a method for contacting the authors of Marlin, but that is probably the most sensible approach.

...R

Thanks for the reply, This is has been done before (See link attached, however I don.t need the microswitch)

You clearly know a great deal more about it than I do.

...R