hi guys im new to the arduino world and im getting to grips with all the different code out there.
ive done a good few examples and i think im getting the hang of it.
im working on a robotic gripper that i got off arduino and i can get it to move using numbers through String commands - which i got off this forum
but i also want to be able to type in the command " close claw" and have the of the servos slowly close the gripper to grip the object
this is the code i have so far. i got it off another topic here, theres an explanation for the bits i added which didnt work. i posted the error messages at the bottom it it helps
#include <Servo.h>
String readString, servo1, servo2, servo3;
Servo myservo1;
Servo myservo2;
Servo myservo3;
Servo closeclaw;
int pos =0;
void setup() {
Serial.begin(9600);
myservo1.attach(6);
myservo2.attach(7);
myservo3.attach(

;
closeclaw.attach(

; // i want the third servo to control the gripper
Serial.println("I am ready");
}
void loop() {
while (Serial.available()) {
delay(3);
if (Serial.available() >0) {
char c = Serial.read();
readString += c;
}
}
if (readString.length() >0) {
Serial.println(readString);
servo1 = readString.substring(0, 3);
servo2 = readString.substring(3, 6);
servo3 = readString.substring(6, 9);
servo3 = readString.substring(closeclaw); // my attempt at getting the
// arduino to recognise "close claw" command
Serial.println(servo1);
Serial.println(servo2);
Serial.println(servo3);
int n1 = servo1.toInt();
int n2 = servo2.toInt();
int n3 = servo3.toInt();
int closeclaw = servo3.toInt();// connecting the close claw command to
//the third serv
Serial.println("move to :");
Serial.println(n1);
Serial.println(n2);
Serial.println(n3);
myservo1.write(n1);
myservo2.write(n2);
myservo3.write(n3);
if(closeclaw){// the arm gipper can bend twist and close with the commands
// but if i type in close claw this is to make sure it closes on the object at a spped i like
{ for(pos=0; pos<180; +=1) }
myservo.write(pos)
delay (40);
}
readString="";
}
/quote]
thanks to anyone who helps out
serial_slow_trial.cpp: In function 'void loop()':
serial_slow_trial:44: error: no matching function for call to 'String::substring(Servo&)'
/Users/thomasoflaherty/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:160: note: candidates are: String String::substring(unsigned int) const
/Users/thomasoflaherty/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/WString.h:161: note: String String::substring(unsigned int, unsigned int) const
serial_slow_trial:72: error: expected primary-expression before '+=' token
serial_slow_trial:72: error: expected primary-expression before '}' token
serial_slow_trial:72: error: expected `;' before '}' token
serial_slow_trial:73: error: 'myservo' was not declared in this scope
serial_slow_trial:79: error: expected `}' at end of input