function-definition is not allowed here before '{' token ERROR

Hi everyone,

I am facing the error in programming of ultrasonic radar system.

The error is,

function-definition is not allowed here before ‘{’ token ERROR

Pls pls help me out with a modified code…

thank u so much…

radar.txt (1.38 KB)

For starter

Serial.begin(9600);
  myServo.attach(10); // Pin Connected To Servo

is outside setup().

There might be more wrong.

(deleted)

pinMode(echoPin, INPUT); // echoPin as an Input
  }  // this curly bracket is in the wrong place.
  Serial.begin(9600);

The misplaced curly bracket ends the setup function early. Move that curly bracket to the end of the setup code like so:

Serial.begin(9600);
  myServo.attach(10); // Pin Connected To Servo
}  // this is where the bracket belongs

alright, this is the only error i am facing and this only the full code.

apologize if i wrote something wrong

Hey I am sharing you the screenshot pls pls respond..

Screenshots are worthless. Read the posting guidelines here.

I don't see a screenshot.

And if it shows code or errors or serial monitor, don't bother. Copy and paste here using code tags (or, in case to big, attach it).

Remember two things: The only thing allowed outside of a function is a variable or function declaration. Functions cannot be declared inside a function.

Hi, PLEASE, PLEASE, PLEASE

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.

Thanks.. Tom... :o