[SOLVED] setupArdumoto error

Hello,
I need help! I am coding a sumo robot. I am still working on the code however I wanted to verify if it is working correctly so far. But when I verified it, it states an error.
It says my setupArdumoto was not declared. However, i thought it would work if I used the void setupArdumoto function. I have pasted the code below, the error message follows it.

#define echoPin 7 // Echo Pin
#define trigPin 8 // Trigger Pin 
#define CW  0 //Define the values for clockwise and counter clockwise 
#define CCW 1
#define MOTOR_A 0 // Define the values for the two motors 
#define MOTOR_B 1
const byte PWMA = 3;  // PWM control (speed) for motor A
const byte PWMB = 11; // PWM control (speed) for motor B
const byte DIRA = 12; // Direction control for motor A
const byte DIRB = 13; // Direction control for motor B
int inPin = 9;        // the number of the input pin
int outPin = 10;      // the number of the output pin
int state = HIGH;     // the current state of the output pin
int reading;          // the current reading from the input pin
int previous = LOW;   // the previous reading from the input pin
long time = 0;        // the last time the output pin was toggled
long debounce = 200;  // the debounce time, increase if the output flickers
int dist = 0;
int object = 500;

void setup() {
 Serial.begin (9600);
 pinMode(trigPin, OUTPUT); // set trigpin as an output
 pinMode(echoPin, INPUT);
 pinMode(inPin, INPUT);
 pinMode(outPin, OUTPUT);
 setupArdumoto(); // Set all pins as outputs
}

void loop() {
 if (reading == HIGH && previous == LOW && millis() - time > debounce) {
   if (state == HIGH)
     state = LOW;
   else
     state = HIGH;

   time = millis();

   if (dist < object) {                        //if distance is less than 550
     attack();                                //move forward and commence attacking by charging at robot

     void attack()
     driveArdumoto(MOTOR_A, CW, 255);  // Motor A at max speed.
     driveArdumoto(MOTOR_B, CW, 255);  // Motor B at max speed.
     return;

     void driveArdumoto(byte motor, byte dir, byte spd)// dirve the motor in a certain direction at certain speed
     {
       if (motor == MOTOR_A)
       {
         digitalWrite(DIRA, dir);
         analogWrite(PWMA, spd);
       }
       else if (motor == MOTOR_B)
       {
         digitalWrite(DIRB, dir);
         analogWrite(PWMB, spd);
       }
     }

     void setupArdumoto()
     {
       // All pins should be setup as outputs:
       pinMode(PWMA, OUTPUT);
       pinMode(PWMB, OUTPUT);
       pinMode(DIRA, OUTPUT);
       pinMode(DIRB, OUTPUT);

       // Initialize all pins as low:
       digitalWrite(PWMA, LOW);
       digitalWrite(PWMB, LOW);
       digitalWrite(DIRA, LOW);
       digitalWrite(DIRB, LOW);
     }
Arduino: 1.6.13 (Windows 7), Board: "Arduino/Genuino Uno"
E:\Arduino\Sumo_Robot_Sketch\Sumo_Robot_Sketch.ino: In function 'void setup()':

Sumo_Robot_Sketch:27: error: 'setupArdumoto' was not declared in this scope

setupArdumoto(); // Set all pins as outputs

             ^

E:\Arduino\Sumo_Robot_Sketch\Sumo_Robot_Sketch.ino: In function 'void loop()':

Sumo_Robot_Sketch:40: error: 'attack' was not declared in this scope

  attack();                                //move forward and commence attacking by charging at robot 

         ^

Sumo_Robot_Sketch:43: error: expected initializer before 'driveArdumoto'

driveArdumoto(MOTOR_A, CW, 255);  // Motor A at max speed.

^

Sumo_Robot_Sketch:44: error: 'driveArdumoto' was not declared in this scope

driveArdumoto(MOTOR_B, CW, 255);  // Motor B at max speed.

                             ^

Sumo_Robot_Sketch:48: error: a function-definition is not allowed here before '{' token

{

^

Sumo_Robot_Sketch:74: error: expected '}' at end of input

}

^

Sumo_Robot_Sketch:74: error: expected '}' at end of input

Sumo_Robot_Sketch:74: error: expected '}' at end of input

exit status 1
'setupArdumoto' was not declared in this scope

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.[/color]

Sumo_Robot_Sketch.ino (2.2 KB)

Sumo_Robot_Sketch:48: error: a function-definition is not allowed here before '{' token

 {

So, don't do that!

If you properly posted your code, you would have used the autoformat function and perhaps found the other errors that you had.

To post code and/or error messages:

  1. Use CTRL-T in the Arduino IDE to autoformat your complete code.
  2. Paste the complete autoformatted code between code tags (the </> button)
    so that we can easily see and deal with your code.
  3. Paste the complete error message between code tags (the </> button)
    so that we can easily see and deal with your messages.
  4. If you already posted without code tags, you may add the code tags by
    editing your post. Do not change your existing posts in any other way.
    You may make additional posts as needed.

Before posting again, you should read the three locked topics at the top of the Programming Questions forum, and any links to which these posts point.

Please fix the other errors and try again. For example, the definition of every function should begin with a “{” and end with a “}”. When you use autoformat, such errors will be indicated by indentation that is wrong.

Good Luck!

I appreciate everyone's help!

vaj4088:
4) If you already posted without code tags, you may add the code tags by
editing your post.

I have corrected the code above. However, I am still not sure about where I accidentally inserted the "{".

Thanks for everyone's help!

I figured out where the "{’ needed to go. Thanks everyone for helping out!