error: expected unqualified-id before '{' token

I have come across a problem that I can't seem to figure out. I have tried everything possible that I could think of but apparently, I haven't thought of everything. If you can please help that would be great.

In line 80 it gives me an error code saying, "error: expected unqualified-id before '{' token"

Line 80 is underlined and bolded.

Thank You in advance

/*
Water Sensor = Port A0
IR Remote = Digital Port 8
Weight Drop Servo = Digital Port 9
Ground Servo = Digital Port 10

*/

#include <Servo.h> //include servo library
Servo myservo; //define servo as servo
const int waterSens = A0;//set water sensor to A0

#include <Servo.h>
Servo yourservo; // create servo object to control a servo
// twelve servo objects can be created on most boards

#include <Servo.h>
Servo Weight;

#include <IRremote.h>
const int irReceiverPin = 6;
IRrecv irrecv(irReceiverPin);
decode_results results;

int pos = 180;//define servo position

//int posi = 0; // variable to store the servo position
void setup()

{
Serial.begin(9600); // servo number 2
yourservo.attach(11); // attaches the servo on pin 9
irrecv.enableIRIn();
Serial.begin(4800); //servo number 1
myservo.attach(7);// attach the servo to pin 10
irrecv.enableIRIn();
Serial.begin(2400); // servo number 3
Weight.attach(9); // attach the servo to pin 11
irrecv.enableIRIn();
}
void loop()

{
int sensorValue = analogRead(waterSens);//read the water sensor value

sensorValue = map(sensorValue, 0, 1023, 0, 180);
if (sensorValue >= 100)
{
for (pos = 9; pos <= 90; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 90; pos >= 9; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position

}
}

else{
myservo.write(90);
}
}
/*

Serial.println(sensorValue);
delay(15);
}

if (irrecv.decode(&results))
{
Serial.print("FF");
for (pos = 180; pos >= 100; pos -= 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
yourservo.write(pos); // tell servo to go to position in variable 'pos'
//delay(1); // waits 15ms for the servo to reach the position
Serial.print(results.value, HEX);
Serial.print(", 32");
Serial.println(results.bits);
irrecv.resume();
//delay(15);
}
/*
for (pos = 180; pos <= 180; pos -= 1) { // goes from 180 degrees to 0 degrees
yourservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}*/
}
else
{ yourservo.write(180);
}

{
for (pos = 90; pos >= 65; pos -= 1) { // goes from 180 degrees to 0 degrees
Weight.write(pos); // tell servo to go to position in variable 'pos'
delay(5); // waits 15ms for the servo to reach the position
}

for (pos = 65; pos <= 90; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
Weight.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the [position
}

}

Enough.

Read the guides.

Post your code properly.

DKWatson:
Enough.

Read the guides.

Post your code properly.

And count your opening and closing braces. Actually - there's no need to count them if you use the autoformat.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

In the IDE select, TOOLS, then select Auto Format.
It will automatically indent your code t6o make it easier to read and set your { and } brackets correctly.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile:

In the IDE select, TOOLS, then select Auto Format.
It will automatically indent your code t6o make it easier to read and set your { and } brackets correctly.

Actually, it won't do a thing except tell you that the number of open and close braces are not the same.

When you have the same number of each (the tool actually tells you whether you need to add { or } to the code), then it will format the code to line the braces up. You'll usually see that you added the missing } in the wrong place. So, you move the incorrectly placed }, and run the tool again.

It is, of course, MUCH better to run the tool often, before you've entered a sh*tload of crappy code.

yourservo? What the hell kind of name is that? That's like getting a dog, and naming it yourdog. Of course, naming it myDog is no better.

You have two Servo objects. That does NOT mean that you need to include the header file twice.

Common compiler errors caused by mismatched brackets:

"does not name a type" or
"expected declaration before" or
"expected unqualified-id before"
Usually means you forgot a '{' or put in an extra '}' in the previous function. Since all of the open brackets have been closed, the compiler is looking for further global declarations (variables or functions). If it finds something that looks like executable code instead of a global declaration it emits an error. Make sure that the brackets in the preceding function are in matching pairs '{' followed by '}'.

"a function-definition is not allowed here before '{' token"
(can cause: "'functionName' was not declared in this scope")
Usually means you forgot a '}' or put in an extra '{' in the previous function. Since a set of brackets has not been closed yet the compiler is looking for more code to put in the function. You can't declare a function inside a function so if the compiler finds a function definition it emits an error. Make sure that the brackets in the preceding function are in matching pairs '{' followed by '}'.

"expected '}' at end of input"
Usually means you forgot a '}' or put in an extra '{' in the last function in the sketch. Since a set of brackets has not been closed yet, the compiler is looking for more code to put in the function. When it hits the end of the file instead it emits an error. Make sure that the brackets in the last function are in matching pairs '{' followed by '}'.

"expected primary-expression before '}' token"
Usually means you have an incomplete statement before a '}'. The block statement (between '{' and matching '}') can only contain complete statements.