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