Serial Servo command using visual basic

I have a piece of code that I am wondering if i could get some help on. I am using visual basic to write a program to control the usb servo controller 6 servo I do not need a complicated script, just something to tell it to go up and pause indeffinitely at a certain position if a button is clicked. Basically i have 2 buttons, one is always activated, when i activate the second i want it to move to about 120 degrees and hold that position until the other button is clicked. Here is the code that I have gotten from here:

SerialPort1.Open()
Dim buffer As Byte() = {128, 1, 0, 12, 79}
SerialPort1.Write(buffer, 0, 5)

From what i understand, the second number in the first string is the device number, or servo number, and the last number is the speed? And then the ‘5’ under the buffer is how long it stays in that position? Any help would be great! And if it could be explained which piece is which that would be great also.

Hello,

These things are all explained in detail by the relevant documentation. I recommend Section 5 of the Maestro User’s Guide and the MSDN documentation for SerialPort.Write.

You need to configure your Maestro correctly for serial communication before it will respond to your commands. Also, the code you found was for a different servo controller, but it can be made to work very easily with the Maestro by changing the bytes to the appropriate values. Try starting with the example given for the set target command.

If you have trouble, start by sending commands with our Serial Transmitter instead of with VB - this way you can test one thing at a time.

Good luck, and please let us know how it goes!

-Paul

The Pololu USB SDK now contains a VB.NET example program for the Maestro that uses native USB, which is nicer than the serial port.

–David