Servo Core

Library for controlling generic servo motors based on the Arduino servo library.


This example uses a generic servo, these are available from a number of suppliers including Adafruit and Sparkfun.


Servo Connected to Netduino

Note the presence of a current limiting resistor in the above circuit.


The following application sweeps the servo from 0 to 180 degrees and then back again. This is repeated continuously:

using System.Threading;
using SecretLabs.NETMF.Hardware.NetduinoPlus;
using Netduino.Foundation.Servos;

namespace ServoTest
    public class Program
        public static void Main()
            Servo servo = new Servo(PWMChannels.PWM_PIN_D9, 1000, 2000);
            while (true)
                for (int angle = 0; angle <= 180; angle++)
                    servo.Angle = angle;
                for (int angle = 179; angle > 0; angle--)
                    servo.Angle = angle;




Get or set the servo angle where the angle is specified in degrees and should be between 0 and 180 inclusive.


Indicate if the servo has a PWM pin associated with it.


Servo(Cpu.PWMChannel pin, int minimum = 544, int maximum = 2400)

The default constructor creates a new ‘Servo’ object with the MinimumPulseWidth set to 544 and the MaximumPulseWidth set to 2400.

In this case the Servo object is not connected to a PWM pin.

Servo(pin, minimum, maximum)

Create a new Servo object and connect it to the specified PWM pin. The MinimumPulseWidth and MaximumPulseWidth are set to the specified values.


void Attach(pin, minimum, maximum)

Attach the Servo object to a PWM pin

void Write(angle)

This is equivalent to setting the Angle property.

double Read()

This is the equivalent to reading the Angle property.

void Detach()

If the Servo is attached to a pin then this method will stop the PWM pulses and release the PWM pin being used to control the servo.

void Stop()

Turn off the PWM pulses being used to control the servo.

void WriteMicroseconds(microseconds)

This method is not implemented and will throw an exception if called.