Has someone written a driver for this Servo controller

I bough this servo controller from pololu.

just checking in this awesome community if someone has already written code for this with gadgeteer.

@ MJ1984 - I used one of their other similar ones awhile back, probably have some code on the office puter I could dig up if no one else posts before then.

1 Like

Thanks a lot Justin. I really appreciate the help.

I will have a squizz in the morning.

Righto - see if the below works, i haven’t tried it so not even sure if it will work as i cant seem to find my servo controller in my highly organised filing system :smiley:


using System;
using System.Threading;
using Gadgeteer.Interfaces;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;

namespace GadgeteerApp1
{
    public partial class Program
    {
        private static GT.Interfaces.Serial _serialPort;
        private GT.Timer _timer;
        private const int MinAngle = 0;
        private const int MaxAngle = 255;

        private void ProgramStarted()
        {
            _serialPort = new GT.Interfaces.Serial(GT.Socket.GetSocket(8, true, null, null), 9600, Serial.SerialParity.None, Serial.SerialStopBits.One, 8, Serial.HardwareFlowControl.NotRequired, null);
            _serialPort.Open();

            _timer = new GT.Timer(2000);
            _timer.Tick += new GT.Timer.TickEventHandler(TimerTick);
            _timer.Start();
        }

        private void TimerTick(GT.Timer timer)
        {
            _timer.Stop();
            for (int i = 50; i < 200; i++)
            {
                MoveServo(_serialPort, 1, i);
                Thread.Sleep(100);
            }
        }

        public static void MoveServo(GT.Interfaces.Serial comPort, int servoNumber, int servoPos)
        {
            if (servoPos < MinAngle || servoPos > MaxAngle)
            {
                return;
            }
            _serialPort.Write(new byte[] { 0xFF, Convert.ToByte(servoNumber.ToString()), Convert.ToByte(servoPos.ToString()) }, 0, 3);
        }
    }
}

Also have a look here http://www.tinyclr.com/codeshare/entry/157

Thanks Justin I will try this and let you know how it goes.