SOLVED exit sta a function-definition is not allowed here before '{' token

Hello all!

Like many others, I am new to this. I am trying to bring an idea to fruition that I had back in 1999, a automated lawn mowing robot. I know they now have them available to purchase, even build kits with code and all the parts, but doing it this way also will help me learn coding/programming, which is something I am deficient in. After procuring parts and writing a basic sketch to check motor and motor driver funtionality, I started writing in parts to use a Left and Right "NO" switch. My intention is for it to default run in forward, if it receives an input from bumpLeft, bumpRight, or both it executes the listed routine. After spending the last 3 days fiddling with it and the ensuing errors etc, and googling looking for trouble shooting with my sketch, I have deleted the both bumper parts to simplify.

I am using an AtMega2560, I have since unplugged board from my prototype robot and built a circuit on a breadboard with LED's to represent "motor run conditions"-Forward, backwards, right bump, left bump.

I am currently getting an error after changing this sketch so many times thus far,

" exit status 1
a function-definition is not allowed here before '{' token "

// Motor A connections
int enA = 9;
int in1 = 8;
int in2 = 7;
// Motor B connections
int enB = 3;
int in3 = 4;
int in4 = 5;
// Bumper switches
const int bumpLeft = 26;           //Left bumper pin D26
const int bumpRight = 27;          //Right bumper pin D27
int pbLeft = LOW;            //Var for left bumper
int pbRight = LOW;           //Var for right bumper
// Turn indicator
int turnLeft = 48;           //Turn Left
int turnRight = 49;          //Turn Right

void setup() {
  // Set all motor control pins to outputs
  pinMode(26, INPUT);
  pinMode(27, INPUT);
  pinMode(enA, OUTPUT);
  pinMode(enB, OUTPUT);
  pinMode(in1, OUTPUT);
  pinMode(in2, OUTPUT);
  pinMode(in3, OUTPUT);
  pinMode(in4, OUTPUT);
  pinMode(48, OUTPUT);
  pinMode(49, OUTPUT);


  // Turn off motors - Initial state
  digitalWrite(in1, LOW);
  digitalWrite(in2, LOW);
  digitalWrite(in3, LOW);
  digitalWrite(in4, LOW);
}


void loop() {
  int  Forward();        //Start forward
  // Test bumper switches
  pbLeft = digitalRead(26);
  pbRight = digitalRead(27);

  // If right bumper hit
  if (digitalRead(27) != LOW) {
    int Stop();
    delay(1000);
    int Reverse();
    delay(1000);
    int turnRight();
    delay(500);

    // If left bumper hit
    if (digitalRead(26) != LOW) {
      int Stop();
      delay(1000);
      int Reverse();
      delay(1000);
      int turnLeft();
      delay(500);
    }

    // Forward
    else {
      int Forward();
    }

  }

  void Forward()    {
    digitalWrite(in1, HIGH);
    digitalWrite(in2, LOW);
    digitalWrite(in3, HIGH);
    digitalWrite(in4, LOW);
  }

  void Reverse()    {
    digitalWrite(in1, LOW);
    digitalWrite(in2, HIGH);
    digitalWrite(in3, LOW);
    digitalWrite(in4, HIGH);
  }

  void Stop()     {
    digitalWrite(in1, LOW);
    digitalWrite(in2, LOW);
    digitalWrite(in3, LOW);
    digitalWrite(in4, LOW);
  }

  void turnLeft()     {
    digitalWrite(in1, LOW);
    digitalWrite(in2, HIGH);
    digitalWrite(in3, HIGH);
    digitalWrite(in4, LOW);
    digitalWrite(48, HIGH);
  }

  void turnRight()    {
    digitalWrite(in1, HIGH);
    digitalWrite(in2, LOW);
    digitalWrite(in3, LOW);
    digitalWrite(in4, HIGH);
    digitalWrite(49, HIGH);
  }

I am not even sure if I am able to get a loop type "condition scan"

My background is Industrial Maintenance, and it has not been easy to stop thinking in terms of a logic(PLC) program where there is a constant ongoing scan.

Thank you in advance for any insight.

sketch_bumper_test_breadboard_v1.0.ino (2.26 KB)

You're missing an ending curly bracket for the loop() function.

Also, get rid the the 'int' that you placed in front of function calls within loop(). For Example:
int Stop();

Fixing those things may bring other errors to light. If so, re-post the new code with complete error messages.

When posting errors please include the entire error message. It is easy to do. There is a button (lower right of the IDE window) called "copy error message". Copy the error and paste into a post in code tags. Paraphrasing the error message leaves out important information.

You are missing a curly bracket (}) to close the loop() function. Use of the IDE autoformat tool (ctrl-t or Tools, Suto Format) would have shown that.

 int  Forward();

All of those function calls have the int before them are in error.
Should be:

Forward();
int turnLeft = 48;  // changed in corrected code
int turnRight = 49;     // changed in corrected code

void turnLeft()

void turnRight()

Can't have 2 things with the same name. Changed the variables.

This compiles.

// Motor A connections
int enA = 9;
int in1 = 8;
int in2 = 7;
// Motor B connections
int enB = 3;
int in3 = 4;
int in4 = 5;
// Bumper switches
const int bumpLeft = 26;           //Left bumper pin D26
const int bumpRight = 27;          //Right bumper pin D27
int pbLeft = LOW;            //Var for left bumper
int pbRight = LOW;           //Var for right bumper
// Turn indicator
int leftTurn = 48;           //Turn Left  ****** changed to avoid conflict
int rightTurn = 49;          //Turn Right ****** changed to avoid conflict

void setup()
{
   // Set all motor control pins to outputs
   pinMode(26, INPUT);
   pinMode(27, INPUT);
   pinMode(enA, OUTPUT);
   pinMode(enB, OUTPUT);
   pinMode(in1, OUTPUT);
   pinMode(in2, OUTPUT);
   pinMode(in3, OUTPUT);
   pinMode(in4, OUTPUT);
   pinMode(48, OUTPUT);
   pinMode(49, OUTPUT);


   // Turn off motors - Initial state
   digitalWrite(in1, LOW);
   digitalWrite(in2, LOW);
   digitalWrite(in3, LOW);
   digitalWrite(in4, LOW);
}


void loop()
{
   Forward();        //Start forward
   // Test bumper switches
   pbLeft = digitalRead(26);
   pbRight = digitalRead(27);

   // If right bumper hit
   if (digitalRead(27) != LOW)
   {
      Stop();
      delay(1000);
      Reverse();
      delay(1000);
      turnRight();
      delay(500);

      // If left bumper hit
      if (digitalRead(26) != LOW)
      {
         Stop();
         delay(1000);
         Reverse();
         delay(1000);
         turnLeft();
         delay(500);
      }

      // Forward
      else
      {
         Forward();
      }

   }
}
void Forward()
{
   digitalWrite(in1, HIGH);
   digitalWrite(in2, LOW);
   digitalWrite(in3, HIGH);
   digitalWrite(in4, LOW);
}

void Reverse()
{
   digitalWrite(in1, LOW);
   digitalWrite(in2, HIGH);
   digitalWrite(in3, LOW);
   digitalWrite(in4, HIGH);
}

void Stop()
{
   digitalWrite(in1, LOW);
   digitalWrite(in2, LOW);
   digitalWrite(in3, LOW);
   digitalWrite(in4, LOW);
}

void turnLeft()
{
   digitalWrite(in1, LOW);
   digitalWrite(in2, HIGH);
   digitalWrite(in3, HIGH);
   digitalWrite(in4, LOW);
   digitalWrite(48, HIGH);
}

void turnRight()
{
   digitalWrite(in1, HIGH);
   digitalWrite(in2, LOW);
   digitalWrite(in3, LOW);
   digitalWrite(in4, HIGH);
   digitalWrite(49, HIGH);
}

@gfvalvo and @groundFungus ...

Thank you so much!!!

You edits was where I made a wrong turn in Albuquerque'

I owe you both a virtual beer!