How to control 6 servos using visual basic 2010

hi i found this form to control one servo motor but i need to control 6 servos
what is the modification that have to made in the VB and arduino codes to control 6 servos

VB2010 cods

[code]Private Sub TrackBar1_MouseUp(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TrackBar1.MouseUp

        If pos < 10 Then
            SerialPort1.Open()
            SerialPort1.Write(0)
            SerialPort1.Write(0)
            SerialPort1.Write(pos)
            Thread.Sleep(500)
            SerialPort1.Close()

        ElseIf pos < 100 Then

            SerialPort1.Open()
            SerialPort1.Write(0)
            SerialPort1.Write(pos)
            Thread.Sleep(500)
            SerialPort1.Close()

        Else

            SerialPort1.Open()
            SerialPort1.Write(pos)
            Thread.Sleep(500)
            SerialPort1.Close()
        End If
        
    End Sub

[/code]

arduino code

#include <Servo.h> 
 
Servo myservo;  

int data[3] = {0,0,0};

int pos = 0;
 
void setup() 
{ 
  Serial.begin(9600);
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object 
  myservo.write(2);
} 
 
 
void loop() 
{ 
  
  if (Serial.available()) {

    for(int i=0; i<4; i++) { data[i]=0; }
    
    int i=0;
    
    delay(100);

    while (Serial.available() > 0) {
      
      data[i] = Serial.read() - 48;
      i++;
    }
    
    pos = (100*data[0]) + (10*data[1]) + data[2];
      
    if( (pos>=0) && (pos<=180))
    {  
      
    if(pos<=1) {pos=2;} //Servo making noise at 0 and 1. Need to be at least 2.
    
    myservo.write(pos);
 
    Serial.println(pos);
    }
      
    pos = 0;
  }
  
  delay(50);
}

please i need to control on servos using trackBars

The trick is to get the VB to talk to the Arduino via the Serial comms port!. Does it? what have you tried?

Mark

PS This is not the place to ask about VB GUI design.

M

osos: what is the modification that have to made in the VB and arduino codes to control 6 servos

I can't help you with the VB side of things but I suggest you chuck that Arduino code in the bin and start again - it's atrocious.

Your first challenge will be to decide how the six servo positions will be sent - do you always send all six positions in a standard format, or do you only send a given servo position when it has changed? You need to decide that before you can design the message format. Then write some VB code to display the GUI and send the appropriate commands to the Arduino, and some Arduino code to receive and process the commands and move the servos.