declaring function error

Hi,

the code below shows me an error of : "exit status 1. a function-definition is not allowed here before '{' token".

I wanted to declare a function returnUGV(). However, i couldn't do so. Is there any problem with my code?

void returnUGV;


void loop(){

void returnUGV(){
  if (UGVSelect == 1 && UGVAction == 'r')
  {
    digitalWrite(ledPin, LOW);

    motorBL->run(BACKWARD); // turn it on going backward
    motorBR->run(BACKWARD);
    motorFL->run(BACKWARD);
    motorFR->run(BACKWARD);
    delay(delayTime);

    locationStatus1.setData("Home"); // change location status to Home
    motorBL->run(RELEASE); // stop
    motorBR->run(RELEASE);
    motorFL->run(RELEASE);
    motorFR->run(RELEASE);

    currentLocation1 = 0;
    UGVAction = 'n';
  }
 }
}

2 things:

1 - you don't need a function declaration when coding in the Arduino IDE
2 - you can't write a function definition within the loop() function (or any other for that matter); do all definitions outside loop();

The first line in the code that you presented is missing the () and hence is a variable; change it to

void returnUGV();

Alright, i got it. Thanks for the help. Much appreciated. :slight_smile: