Servo Class

Class for controlling standard fixed rotation servos.


The Servo class inherits from ServoBase and therefore implements IServo. It’s used to control standard fixed-rotation servos.

Creating a new Servo

The Servo constructor takes two parameters; the PWMChannel pin that the servo control pin is hooked up to, and a ServoConfig describing the control parameters of the servo.

In addition to manually instantiating a ServoConfig class, the NamedServoConfigs class contains a set of known servo configurations and can be used instead:

IServo servo = new Servo(N.PWMChannels.PWM_PIN_D9, NamedServoConfigs.BlueBirdBMS120);

Rotating the Servo via RotateTo()

To rotate a fixed-range servo, you simply call the RotateTo method and pass the angle. For instance, the following code rotates a servo to its maximum angle:


Test Circuit

To test the servo, the following circuit can be used.

Servo Connected to Netduino

Note that under load, a servo can use a lot of power, and therefore it should be powered via an external power source. See the ServoCore guide for more information.


This sample app will toggle the servo between it’s minimum and maximum rotation angles when the button on the Netduino is clicked.

using Microsoft.SPOT;
using Netduino.Foundation;
using Netduino.Foundation.Sensors.Buttons;
using Netduino.Foundation.Servos;
using System.Threading;
using H = Microsoft.SPOT.Hardware;
using N = SecretLabs.NETMF.Hardware.Netduino;

namespace ServoSample
    public class Program
        static IServo _servo = null;
        static PushButton _button = null;

        public static void Main()
            _servo = new Servo(N.PWMChannels.PWM_PIN_D9, 
            _button = new PushButton((H.Cpu.Pin)0x15, 

            _button.Clicked += (object sender, Microsoft.SPOT.EventArgs e) =>
                Debug.Print("Button Clicked");


        static void ToggleServo()
            if (_servo.Angle == _servo.Config.MinimumAngle)
                Debug.Print("Rotating to " + 
                Debug.Print("Rotating to " +