Well first of all, try compiling it. It doesn't compile at all.
There are several issues.
Firstly, you cannot declare a struct like this:
typedef struct {
byte servoValue;
byte servoVal;
int iFinger;
} DEFAULT servo[MAX_FINGER];
Try this instead:
typedef struct {
byte servoValue;
byte servoVal;
int iFinger;
} SERVO;
SERVO servo[MAX_FINGER];
Notice that DEFAULT cannot be used as it is a #define in another part of the Arduino core (part of analogRead()). Secondly you can't create a struct at the same time as you define it. You have to seperate the creation of an object from the creation of a type.
For the servo side, you forgot this line:
#include <Servo.h>
Which goes at the very top and includes the servo library.
There is one place in your code where you have used a '-' sign instead of an '=' sign. In another place you missed a ')'.
The next thing to point out is that if you format the code correctly (autoformat helps), then it is easier to read.
After fixing those, you get this:
Code1:
#include <Servo.h>
#define MAX_FINGER 5
// #include
// create servo object to control a servo
typedef struct {
Servo myservo;
byte servoAng;
} SERVO;
SERVO servo[MAX_FINGER];
void setup() {
Serial.begin(9600);
int i = 0;
for (i = 0; i < MAX_FINGER; i++) {
servo[i].myservo.attach(i + 2);
}
}
void loop() {
if(Serial.available() >=5) {
int i = 0;
for (i = 0; i < MAX_FINGER; i++) {
servo[i].servoAng = Serial.read();
servo[i].myservo.write( servo[i].servoAng );
}
// Send the servo to the position read... (note: you get to make this happen)
}
}
Code2:
#define MAX_FINGER 5
typedef struct {
byte servoValue;
byte servoVal;
int iFinger;
} SERVO;
SERVO servo[MAX_FINGER];
const int ciDefault[] = { 200, 460};
void setup() {
Serial.begin(9600);
}
void init_default() {
int i = 0;
for (i = 0; i < MAX_FINGER; i++) {
servo[i].iFinger = analogRead(i);
if (servo[i].iFinger < ciDefault[0]) servo[i].iFinger = ciDefault[0];
else if (servo[i].iFinger > ciDefault[1]) servo[i].iFinger = ciDefault[1];
servo[i].servoVal = map(servo[i].iFinger, 460, 200, 255, 0);
Serial.print(servo[i].servoVal);
}
}
void loop() {
init_default();
delay(100);
}
Which compiles. Whether it works or not, I haven't looked through it to see (it is 1am here and I am off to bed).