This code example demonstrates using PWM (i.e. pulse width modulation) port(s) to control servo’s connected to a GHI Electronics FEZ board.
This code is written in C# and assumes the development workstation has all required software installed.
using System;
using System.Threading;
using Microsoft.SPOT;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.Hardware;
namespace FEZ_Mini_Application1
{
class Program
{
public static void Main()
{
PWM servo = new PWM((PWM.Pin)FEZ_Pin.PWM.Di5);
while (true)
{
servo.SetPulse(20 * 1000 * 1000, 1250 * 1000);
Thread.Sleep(1000);//wait for a second
servo.SetPulse(20 * 1000 * 1000, 1500 * 1000);
Thread.Sleep(1000);//wait for a second
servo.SetPulse(20 * 1000 * 1000, 1750 * 1000);
Thread.Sleep(1000);//wait for a second
}
}
}
}
For more information on specific namespaces please refer to the following resources: