Expected unqualified-id before '{' token

I am trying to figure out where the error is, and how to fix it. Please help! Here is the program:

#include <Servo.h>

Servo doorServo;

Servo fingerServo;

int swPin = 2; //switch on pin 2

int pos = 0;

int selectedMove = 0; //move selector

void setup()

{

pinMode(swPin, INPUT);

doorServo.attach(9); //set door servo on Pin 9 pwm

fingerServo.attach(6); //set finger servo on Pin 6 pwm

doorServo.write(80); //set door to hiding position

fingerServo.write(0); //set finger to hiding position

}

{ void loop()

// basic move 1

{void switchoff()

//Moving door

{ for(pos = 80; pos < 155; pos += 3)

{

doorServo.write(pos);

delay(15);

}

//Moving finger

for(pos = 0; pos < 180; pos += 4)

{

fingerServo.write(pos);

delay(15);

}

//hiding finger

for(pos = 180; pos>=0; pos-=4)

{

fingerServo.write(pos);

delay(15);

}

//hiding door

for(pos = 155; pos>=80; pos-=3)

{

doorServo.write(pos);

delay(25);

}

}

// basic move 1

void switchoff()

{

//Moving door

for(pos = 80; pos < 155; pos += 3)

{

doorServo.write(pos);

delay(15);

}

//Moving finger

for(pos = 0; pos < 180; pos += 4)

{

fingerServo.write(pos);

delay(15);

}

//hiding finger

for(pos = 180; pos>=0; pos-=4)

{

fingerwrite(pos);

delay(15);

}

//hiding door

for(pos = 155; pos>=80; pos-=3)

{

doorServo.write(pos);

delay(25);

}

}

Your braces { } are really mixed up.

Where does loop()'s definition start and end? It should start with a { and end with a }

Why is there an opening brace { at the start of the void loop() line?

EDIT: also you can't define a function inside another function.

...and please remember to use code tags when posting code

So my friend and I are really new to this (it´s a school project) and we are so confused. Which braces are mixed up?

Just about all of them.

Look in the examples in the IDE

Yeah, time to start again - build up your sketch in stages. Write the first bit. Test it. If it works, add the next bit. If it doesn't work, fix it.

It's an iterative process.

It's a bad idea to write loads of code in one go because it's hard to keep control of errors.

What does ´ expected initializer before 'for' ´ mean?

The error is occurring here: for(pos = 80; pos < 155; pos += 3)

When we try to put in a { we get this message: a function-definition is not allowed here before '{' token

What to do?

AsstridL:
So my friend and I are really new to this (it´s a school project) and we are so confused. Which braces are mixed up?

Every { must have a corresponding } but they must be in the right place. Ckicking to the right of any { will cause the IDE to put a box round the corresponding } to that you can easily see what is in the code block

Do yourself a favour and Auto Format your code in the IDE and use code tags when posting code here. This is your code Auto Formatted

#include <Servo.h>

Servo doorServo;
Servo fingerServo;

int swPin = 2;               //switch on pin 2
int pos = 0;
int selectedMove = 0;             //move selector

void setup()

{
  pinMode(swPin, INPUT);
  doorServo.attach(9);           //set door servo on Pin 9 pwm
  fingerServo.attach(6);          //set finger servo on Pin 6 pwm
  doorServo.write(80);           //set door to hiding position
  fingerServo.write(0);            //set finger to hiding position
}

{
  void loop()
  // basic move 1
  {
    void switchoff()
    //Moving door
    {
      for (pos = 80; pos < 155; pos += 3)
      {
        doorServo.write(pos);
        delay(15);
      }
      //Moving finger
      for (pos = 0; pos < 180; pos += 4)
      {
        fingerServo.write(pos);
        delay(15);
      }
      //hiding finger
      for (pos = 180; pos >= 0; pos -= 4)
      {
        fingerServo.write(pos);
        delay(15);
      }
      //hiding door
      for (pos = 155; pos >= 80; pos -= 3)
      {
        doorServo.write(pos);
        delay(25);
      }
    }
    // basic move 1
    void switchoff()
    {
      //Moving door
      for (pos = 80; pos < 155; pos += 3)
      {
        doorServo.write(pos);
        delay(15);
      }
      //Moving finger
      for (pos = 0; pos < 180; pos += 4)
      {
        fingerServo.write(pos);
        delay(15);
      }
      //hiding finger
      for (pos = 180; pos >= 0; pos -= 4)
      {
        fingerwrite(pos);
        delay(15);
      }
      //hiding door
      for (pos = 155; pos >= 80; pos -= 3)
      {
        doorServo.write(pos);
        delay(25);
      }
    }

All function definitions, such as loop(), should start on the left margin when Auto Formatted. Yours don't. This is usually a sign that there is a problem with { and/or }

Try to identify where the matching } is for each of your {