Variable Declared in a Scope

Hi,
I am working on a sketch for a robotic arm and I keep getting the same error messages over and over. I have attempted to include the proper variables to fix the program but nothing seems to be working. Any assistance would be appreciated. I will attach the program and error messages.

Robotic Arm sketch error messages.txt (3.03 KB)

RoboticArm sketch.txt (1.97 KB)

Your code as attached does not have the servo objects or variables declared, nor does it #include the Servo library. Is it complete ?

Why don't you just post the code instead of forcing people to download it?

Well, I'm a novice in c coding. I thought it was finished but I guess it isn't.

Here is the code

int mpos = 0;
int ipos = 0;
int tpos = 0;
void setup()
{
//Show which servo is connected to which pin
ring.attach(5);
middle.attach(4);
index.attach(3);
thumb.attach(2);
//set all servos to starting position
pinky.write(0);
ring.write(0);
middle.write(0);
index.write(0);
thumb.write(0);
Serial.begin(9600); //start serial output at 9600
Serial.println("WE WORK!!");
Serial.println("q = close pinky");
Serial.println("a = open pinky");
Serial.println("w = close ring finger");
Serial.println("s = open ring finger");
Serial.println("e = close middle finger");
Serial.println("d = open middle finger");
Serial.println("r = ring finger");
Serial.println("f = open index finger");
Serial.println("t = close thumb");
Serial.println("g = close thumb");
Serial.println("c = close hand");
Serial.println("v = ring finger");
}
void loop()
{
if (Serial.available()) {
val = Serial.read();
if (val == 'q') { //close pinky
ppos = 180;
}
if (val == 'a') { //open pinky
ppos = 0;
}
if (val == 'w') { //close ring finger
rpos = 180;
ring.write(rpos);
}
if (val == 's') { //open ring finger
rpos = 0;
ring.write(rpos);
}
if (val == 'e') { //close middle finger
mpos = 180;
middle.write(mpos);
}
if (val == 'd') { //open middle finger
mpos = 0;
middle.write(mpos);
}
if (val == 'r') { //close index finger
ipos = 180;
index.write(ipos);
}
if (val == 'f') { //open index finger
ipos = 0;
index.write(ipos);
}
if (val == 't') { //close thumb
tpos = 180;
thumb.write(tpos);
}
if (val == 'g') { //open thumb
tpos = 0;
thumb.write(tpos);
}
if (val == 'c') { //close whole hand
ppos = 180;
ring.write(ppos);
middle.write(ppos);
index.write(ppos);
thumb.write(ppos);
}
if (val == 'v') { //open whole hand
ppos = 0;
ring.write(ppos);
middle.write(ppos);
index.write(ppos);
thumb.write(ppos);
}
}
}

Please read these two posts:

How to use this forum - please read.
and
Read this before posting a programming question ...

You have posted code without using code tags. The code tags make the code look

like this

when posting source code files. It makes it easier to read, and can be copied with a single mouse click. Also, if you don't do it, some of the character sequences in the code can be misinterpred by the forum code as italics or funny emoticons.
If you have already posted without using code tags, open your message and select "modify" from the pull down menu labelled, "More", at the lower left corner of the message. Highlight your code by selecting it (it turns blue), and then click on the "</>" icon at the upper left hand corner. Click on the "Save" button. Code tags can also be inserted manually in the forum text using the code and /code metatags.

By the way, I see that you have not created any servo objects, or even #included any servo library.

Look at the examples 0 like the one for servos!

Mark

Einstein6870:
Well, I'm a novice in c coding. I thought it was finished but I guess it isn't.

You have previous threads about a similar subject that I contributed to where the problem was that you created servo objects and then got their name wrong in subsequent code, so your excuse does not really hold water.

http://forum.arduino.cc/index.php?topic=340945.msg2350612#msg2350612

Here is the code

int mpos = 0;

You omit the most important part of the code...
ok, a copyright notice is not required,
but any #include line etc. is really relevant.

Otherwise, your line

 ring.attach(5);

is pure nonsense.