# exit status 1 'checkBTcmd' was not declared in this scope

**URL:** <https://forum.arduino.cc/t/exit-status-1-checkbtcmd-was-not-declared-in-this-scope/429080>\
**Category:** Programming\
**Created:** [January 5, 2017, 6:05pm UTC](https://forum.arduino.cc/t/exit-status-1-checkbtcmd-was-not-declared-in-this-scope/429080 "2017-01-05T18:05:50Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![eamo100](https://avatars.discourse-cdn.com/v4/letter/e/ebca7d/32.png) [@eamo100](https://forum.arduino.cc/u/eamo100)\
**Post date:** [January 5, 2017, 6:05pm UTC](https://forum.arduino.cc/t/exit-status-1-checkbtcmd-was-not-declared-in-this-scope/429080/1 "2017-01-05T18:05:50Z")

</div>

Hi got this code from here for motor control, but I keep getting the same this error can anyone tell me what is wrong?  
The code is taken from Marcelo Rovai page on hacking a radio control car, No mater i copy the code or write it I keep getting the same error!!!  
Anyway on contacting the author Marcelo Rovai????

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

void loop()  
{  
checkBTcmd(); // verify if a comand is received from BT remote control  
receiveCmd ();

if (turnOn) manualCmd ();  
else stopRobot ();  
}

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [January 5, 2017, 6:08pm UTC](https://forum.arduino.cc/t/exit-status-1-checkbtcmd-was-not-declared-in-this-scope/429080/2 "2017-01-05T18:08:15Z")

</div>

> The code is taken from Marcelo Rovai page on hacking a radio control car,

You want US to find that for you? Fat chance.

> checkBTcmd' was not declared in this scope

So, in what scope HAVE you declared that function?

---

<div class="post-metadata">

**Author:** ![eamo100](https://avatars.discourse-cdn.com/v4/letter/e/ebca7d/32.png) [@eamo100](https://forum.arduino.cc/u/eamo100)\
**Post date:** [January 5, 2017, 6:22pm UTC](https://forum.arduino.cc/t/exit-status-1-checkbtcmd-was-not-declared-in-this-scope/429080/3 "2017-01-05T18:22:44Z")

</div>

Sorry, I'm new to all this, I haven't done much of this before. So i just copied the code, but that is all i keep getting. I'm not sure about what scope it is, this is the very first few lines of the code,

---

<div class="post-metadata">

**Author:** ![evanmars](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/evanmars/32/217678_2.png) [@evanmars](https://forum.arduino.cc/u/evanmars)\
**Post date:** [January 5, 2017, 6:26pm UTC](https://forum.arduino.cc/t/exit-status-1-checkbtcmd-was-not-declared-in-this-scope/429080/4 "2017-01-05T18:26:42Z")

</div>

Is that all of the code that you copied?

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [January 5, 2017, 6:31pm UTC](https://forum.arduino.cc/t/exit-status-1-checkbtcmd-was-not-declared-in-this-scope/429080/5 "2017-01-05T18:31:02Z")

</div>

So where did you copy the code from? Post the link.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [January 5, 2017, 6:32pm UTC](https://forum.arduino.cc/t/exit-status-1-checkbtcmd-was-not-declared-in-this-scope/429080/6 "2017-01-05T18:32:29Z")

</div>

> this is the very first few lines of the code,

The stickies at the top of the forum - the ones you were supposed to read before posting here - say to post ALL of your code. Most likely, you have a function with a similar name, but some letters are capitalized in the function but not in the call, or you have a misplaced curly braces.

Read the stickies, and post ALL of your code correctly. This IS a test.

---

<div class="post-metadata">

**Author:** ![eamo100](https://avatars.discourse-cdn.com/v4/letter/e/ebca7d/32.png) [@eamo100](https://forum.arduino.cc/u/eamo100)\
**Post date:** [January 5, 2017, 7:14pm UTC](https://forum.arduino.cc/t/exit-status-1-checkbtcmd-was-not-declared-in-this-scope/429080/7 "2017-01-05T19:14:13Z")

</div>

Sorry i had to pop out,

Here is the Link  
[https://create.arduino.cc/projecthub/mjrovai/hacking-a-rc-car-to-control-it-using-an-android-device-7d5b9a](https://create.arduino.cc/projecthub/mjrovai/hacking-a-rc-car-to-control-it-using-an-android-device-7d5b9a)  
All the code is there

---

<div class="post-metadata">

**Author:** ![eamo100](https://avatars.discourse-cdn.com/v4/letter/e/ebca7d/32.png) [@eamo100](https://forum.arduino.cc/u/eamo100)\
**Post date:** [January 5, 2017, 7:19pm UTC](https://forum.arduino.cc/t/exit-status-1-checkbtcmd-was-not-declared-in-this-scope/429080/8 "2017-01-05T19:19:36Z")

</div>

void loop()  
{  
checkBTcmd(); // verify if a comand is received from BT remote control  
receiveCmd ();

if (turnOn) manualCmd ();  
else stopRobot ();  
}  
void checkBTcmd()  
{  
if (BT1.available())  
{  
command = BT1.read();  
BT1.flush();  
}  
}

void receiveCmd ()  
{

switch (command)  
{  
case 'p':  
Serial.println("command ==\> p");  
turnOn = !turnOn;  
command = 0;  
analogWrite(ledStatus, turnOn\*128); // Robot ON - Led ON  
beep(outBuz, 1000, 100);  
BT1.print(" COMMAND ON/OFF");  
BT1.println('\n');  
delay(200); //Delay to call attention to mode change  
break;

case 'm': //not used here  
break;  
}  
}  
void manualCmd()  
{  
switch (command)  
{  
case 'f':  
moveStop(); //turn off both motors  
state = command;  
break;

case 'w':  
moveForward();  
state = command;  
break;

case 'd':  
moveRight();  
break;

case 'a':  
moveLeft();  
break;

case 's':  
moveBackward();  
state = command;  
break;

case '+':  
if (state == 'w')  
{  
motorSpeed = motorSpeed + 10;  
if (motorSpeed \> MAX\_SPEED)  
{  
motorSpeed = MAX\_SPEED;  
}  
command = 'w';  
} else {command = state;}  
break;

case '-':

if (state == 'w')  
{  
motorSpeed = motorSpeed - 10;  
}  
if (motorSpeed \< MIN\_SPEED )  
{  
motorSpeed = MIN\_SPEED;  
}  
Serial.println(motorSpeed);  
command = state;  
break;  
}  
}  
void moveForward() // rear motor FW  
{  
analogWrite(rearMtEne, motorSpeed);  
digitalWrite(rearMtFw, HIGH);  
digitalWrite(rearMtBw, LOW);

digitalWrite(frontMtEne, LOW);  
digitalWrite(ledRed, LOW);  
delay(5);  
}  
void stopRobot ()  
{  
digitalWrite(ledBlue, LOW);  
digitalWrite(ledRed, LOW);

state = 0;  
moveStop(); //turn off both motors  
}  
// Motor Drives  
const int rearMtFw = 4; // Rear Motor - FW  
const int rearMtBw = 7; // Rear Motor - BW  
const int rearMtEne = 6; // Rear Motor - enable  
const int frontMtLeft = 2; // Front Motor - turn Left  
const int frontMtRight = 3; // Front Motor - turn right  
const int frontMtEne = 5; // Front Motor enable  
void moveForward() // rear motor FW  
{  
analogWrite(rearMtEne, motorSpeed);  
digitalWrite(rearMtFw, HIGH);  
digitalWrite(rearMtBw, LOW);

digitalWrite(frontMtEne, LOW);  
digitalWrite(ledRed, LOW);  
delay(5);  
}  
void moveBackward() // rear motor BW  
{  
analogWrite(rearMtEne, motorSpeed);  
digitalWrite(rearMtFw, LOW);  
digitalWrite(rearMtBw, HIGH);

digitalWrite(frontMtEne, LOW);  
digitalWrite(ledRed, HIGH);  
delay(5);  
}  
void moveLeft() // front motor left  
{  
digitalWrite(frontMtEne, HIGH);  
digitalWrite(frontMtLeft, HIGH);  
digitalWrite(frontMtRight, LOW);  
digitalWrite(ledRed, LOW);  
delay(10);  
}

//\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*//

void moveRight() // front motor right  
{  
digitalWrite(frontMtEne, HIGH);  
digitalWrite(frontMtLeft, LOW);  
digitalWrite(frontMtRight, HIGH);  
digitalWrite(ledRed, LOW);  
delay(10);  
}  
void stopRobot ()  
{  
digitalWrite(ledBlue, LOW);  
digitalWrite(ledRed, LOW);

state = 0;  
moveStop(); //turn off both motors  
}

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [January 5, 2017, 7:27pm UTC](https://forum.arduino.cc/t/exit-status-1-checkbtcmd-was-not-declared-in-this-scope/429080/9 "2017-01-05T19:27:55Z")

</div>

When I compile the code you improperly posted (You FAILED the test), I get:

> sketch\_jan05b.ino: In function 'void loop()':  
> sketch\_jan05b:6: error: 'turnOn' was not declared in this scope  
> sketch\_jan05b.ino: In function 'void checkBTcmd()':  
> sketch\_jan05b:11: error: 'BT1' was not declared in this scope  
> sketch\_jan05b:13: error: 'command' was not declared in this scope  
> sketch\_jan05b.ino: In function 'void receiveCmd()':  
> sketch\_jan05b:21: error: 'command' was not declared in this scope  
> sketch\_jan05b:25: error: 'turnOn' was not declared in this scope  
> sketch\_jan05b:27: error: 'ledStatus' was not declared in this scope  
> sketch\_jan05b:28: error: 'outBuz' was not declared in this scope  
> sketch\_jan05b:28: error: 'beep' was not declared in this scope  
> sketch\_jan05b:29: error: 'BT1' was not declared in this scope  
> sketch\_jan05b.ino: In function 'void manualCmd()':  
> sketch\_jan05b:40: error: 'command' was not declared in this scope  
> sketch\_jan05b:43: error: 'moveStop' was not declared in this scope  
> sketch\_jan05b:44: error: 'state' was not declared in this scope  
> sketch\_jan05b:68: error: 'motorSpeed' was not declared in this scope  
> sketch\_jan05b:69: error: 'MAX\_SPEED' was not declared in this scope  
> sketch\_jan05b:81: error: 'motorSpeed' was not declared in this scope  
> sketch\_jan05b:83: error: 'motorSpeed' was not declared in this scope  
> sketch\_jan05b:83: error: 'MIN\_SPEED' was not declared in this scope  
> sketch\_jan05b:87: error: 'motorSpeed' was not declared in this scope  
> sketch\_jan05b.ino: In function 'void moveForward()':  
> sketch\_jan05b:94: error: 'rearMtEne' was not declared in this scope  
> sketch\_jan05b:94: error: 'motorSpeed' was not declared in this scope  
> sketch\_jan05b:95: error: 'rearMtFw' was not declared in this scope  
> sketch\_jan05b:96: error: 'rearMtBw' was not declared in this scope  
> sketch\_jan05b:98: error: 'frontMtEne' was not declared in this scope  
> sketch\_jan05b:99: error: 'ledRed' was not declared in this scope  
> sketch\_jan05b.ino: In function 'void stopRobot()':  
> sketch\_jan05b:104: error: 'ledBlue' was not declared in this scope  
> sketch\_jan05b:105: error: 'ledRed' was not declared in this scope  
> sketch\_jan05b:107: error: 'state' was not declared in this scope  
> sketch\_jan05b:108: error: 'moveStop' was not declared in this scope  
> sketch\_jan05b.ino: In function 'void moveForward()':  
> sketch\_jan05b:117: error: redefinition of 'void moveForward()'  
> sketch\_jan05b:92: error: 'void moveForward()' previously defined here  
> sketch\_jan05b:119: error: 'motorSpeed' was not declared in this scope  
> sketch\_jan05b:124: error: 'ledRed' was not declared in this scope  
> sketch\_jan05b.ino: In function 'void moveBackward()':  
> sketch\_jan05b:129: error: 'motorSpeed' was not declared in this scope  
> sketch\_jan05b:134: error: 'ledRed' was not declared in this scope  
> sketch\_jan05b.ino: In function 'void moveLeft()':  
> sketch\_jan05b:142: error: 'ledRed' was not declared in this scope  
> sketch\_jan05b.ino: In function 'void moveRight()':  
> sketch\_jan05b:153: error: 'ledRed' was not declared in this scope  
> sketch\_jan05b.ino: In function 'void stopRobot()':  
> sketch\_jan05b:156: error: redefinition of 'void stopRobot()'  
> sketch\_jan05b:102: error: 'void stopRobot()' previously defined here  
> sketch\_jan05b:158: error: 'ledBlue' was not declared in this scope  
> sketch\_jan05b:159: error: 'ledRed' was not declared in this scope  
> sketch\_jan05b:161: error: 'state' was not declared in this scope  
> sketch\_jan05b:162: error: 'moveStop' was not declared in this scope

So, not only did you NOT post the code correctly, you did not post ALL of it.

---

<div class="post-metadata">

**Author:** ![eamo100](https://avatars.discourse-cdn.com/v4/letter/e/ebca7d/32.png) [@eamo100](https://forum.arduino.cc/u/eamo100)\
**Post date:** [January 5, 2017, 7:40pm UTC](https://forum.arduino.cc/t/exit-status-1-checkbtcmd-was-not-declared-in-this-scope/429080/10 "2017-01-05T19:40:27Z")

</div>

Sorry i just copied and that's all was there, that is why I'm on here!!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [January 5, 2017, 8:10pm UTC](https://forum.arduino.cc/t/exit-status-1-checkbtcmd-was-not-declared-in-this-scope/429080/11 "2017-01-05T20:10:17Z")

</div>

(deleted)

---

<div class="post-metadata">

**Author:** ![sterretje](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/sterretje/32/391294_2.png) [@sterretje](https://forum.arduino.cc/u/sterretje)\
**Post date:** [January 6, 2017, 2:21am UTC](https://forum.arduino.cc/t/exit-status-1-checkbtcmd-was-not-declared-in-this-scope/429080/12 "2017-01-06T02:21:15Z")

</div>

This is the link where the code comes from [Hacking a RC car to control it using an Android device](https://create.arduino.cc/projecthub/mjrovai/hacking-a-rc-car-to-control-it-using-an-android-device-7d5b9a).

You have only implemented the loop() function. You're missing pieces. Step 7 starts with the loop() which gives you the basic framework; you copied that. A few lines later Marcelo shows the code for the checkBTcmd() function; copy that from the page and paste it after the loop() function so it looks like

```cpp
void loop() 
{
  checkBTcmd();  // verify if a comand is received from BT remote control
  receiveCmd ();
  
  if (turnOn) manualCmd ();
  else stopRobot ();
}

void checkBTcmd()  
{ 
  if (BT1.available()) 
  { 
    command = BT1.read();
    BT1.flush();
  }
}

```

Do this for all the code blocks that Marcelo gives on that page.

There is however a piece missing (the setup() function and some other stuff). Go to the [github page](https://github.com/Mjrovai/MJRoBot-AutoBot) as @spycatcher2k indicated; you could have found the link near the bottom of the article.

Click the 'clone or download' button and download the zip. Extract the files; you will get the below directories and files.

```cpp
MJROBOT-AUTOBOT-MASTER
\---MJRoBot-AutoBot-master
    |  README.md
    |
    \---MJRoBot_AutoBot_Arduino_Code
            generalFuntions.ino
            MJRoBot_AutoBot.ino
            motorRobot.ino
            robotDefines.h

```

Rename the directory _MJRoBot\_AutoBot\_Arduino\_Code_ to _MJRoBot\_AutoBot_. Double-click the _MJRoBot\_AutoBot.ino_ file in the renamed directory and you should be good to go.

Marcelo has split the code over several files; study them and ask questions if you don't understand something.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [May 5, 2021, 10:15pm UTC](https://forum.arduino.cc/t/exit-status-1-checkbtcmd-was-not-declared-in-this-scope/429080/13 "2021-05-05T22:15:49Z")

</div>


