Hi again.
Glad to be of help. I don't know much about controlling servos but can give a few comments on the communications part of the code...
In the Visual Basic code I'd suggest you use more than one text box - one for each servo. It would make dealing with what's entered a bit easier.
In the code you currently have if you enter '
1180 290' into the same text box then..
Dim head As Byte = CByte(myString.Substring(1, 1))
Dim butt As Byte = CByte(myString.Substring(1))
... head will equal
1 and butt will also equal
1!
myString.substring() returns as many characters (not words) as you ask it to. In both of the myString.Substrings you use you're asking for character at index 1 - the second 1 in the string. Strings are zero indexed in VB so the first character of a string is at index 0.
If you want to get the 1180 from the text box you would need the code
myString.Substring(0, 4) and to get the 290 from it you would need the code
myString.Substring(5, 3).
If, as i'm guessing, you're trying to get the 180 and the 90 then the codes should be...
Dim head As Byte = CByte(myString.Substring(1, 3))
Dim butt As Byte = CByte(myString.Substring(6, 2))
...that's assuming you've got a space between the 1180 and the 290.
Whilst this will work it will cause you problems if in future you use values of different lengths. For example if you want the next instruction to be '15 220' then you'd have to write completely different substring codes. Probably easier to have separate text boxes for each servo. Then you wouldn't need to use substrings at all or numbers to identify the servo...
Dim head As Byte = CByte(TextBox1.Text)
Dim butt As Byte = CByte(TextBox2.Text)
You would still need to make sure the numbers you were entering in each text box were only between 0-255 as a byte can't hold any more. It would also be a good idea to do some checking of the text entered into the text boxes to make sure they are valid numbers and not letters, spaces or punctuation. If they are you're program will throw all sorts of exceptions. This might help with that
http://www.acraigie.com/programming/bitstobytes.html