Hi guys if you've seen some of my other posts you'll know I'm a newbie to microcontrollers and c++. One issue I am having with my coding is as mentioned in the subject error's saying check was not declared in this scope. From my understanding you don't have to declare a check as something else so I am unsure as to what the issue is. I will attach an image of the issue underneath. Thanks for the help and patience guys/girls! ![]()
char dataIn = 'S';Â Â Â //CharacterData coming from the phone.
int pinLeftTrackFB = 13;Â Â //Pin controls left track bank forward and backward.
int pinRightTrackFB = 14;Â //Pin controls right track bank forward and backward.
int BrakeLeftTrackFB = 8;Â //Pin that enables/disables the left track bank.
int BrakeRightTrackFB = 15;Â //Pin that enables/disables the right track bank
int pinLeftRightSpeed = 3;Â //Pin that sets the speed for the Left-Right motor.
int pinLeftTrackSpeed = 11;Â //Pin that sets the speed for the Left track bank.
int pinRightTrackSpeed = 16;Â //Pin that sets the speed for the Right track bank.
int pinBrakeLeftTrackFB = 1;Â //Pin that brakes left track.
int pinBrakeRightTrackFB = 2;Â //Pin that brakes right track.
int pincamerapower = 4;Â Â //Pin that activates power to front camera.
int pinlights = 7; //Pin turns on led’s around tank.
char determinant;Â Â //Used in the check function, stores the character received from the phone.
char det;Â Â //Used in the loop function, stores the character received from the phone.
int velocity = 0;Â Â //Stores the speed based on the character sent by phone.
void setup()
{
//Â NOTE: Once Bluetooth module is received find the Bluetooth unit number and put it in brackets of serial begin.
Serial.begin(24634);Â //Initialize serial communication with Bluetooth module at underlined number btu.
pinMode(pinLeftTrackFB, OUTPUT);
pinMode(pinRightTrackFB, OUTPUT);
pinMode(pinBrakeLeftTrackFB, OUTPUT);
pinMode(pinBrakeRightTrackFB, OUTPUT);
pinMode(pinLeftRightSpeed, OUTPUT);
pinMode(pinLeftTrackSpeed, OUTPUT);
pinMode(pinRightTrackSpeed, OUTPUT);
pinMode(pincamerapower, OUTPUT);
pinMode(pinlights, OUTPUT);
}
void loop()
{
 det = check();
  while (det == 'F') //If incoming data is an F, denotes the function move forward
  {
digitalWrite(pinLeftTrackFB, LOW);
digitalWrite(pinRightTrackFB, LOW);
digitalWrite(pinBrakeLeftTrackFB, LOW);
digitalWrite(pinBrakeRightTrackFB, LOW);
analogWrite(pinLeftTrackFB, velocity);
analogWrite(pinRightTrackFB, velocity);
analogWrite(pinLeftTrackSpeed,255);
analogWrite(pinRightTrackSpeed,255);
det = check();
}
   while (det == 'B') //if incoming data is a B, move back
   { Â
digitalWrite(pinLeftTrackFB, HIGH);
digitalWrite(pinRightTrackFB, HIGH);
digitalWrite(pinBrakeLeftTrackFB, LOW);
digitalWrite(pinBrakeRightTrackFB, LOW);
analogWrite(pinLeftTrackFB, velocity);
analogWrite(pinRightTrackFB, velocity);
analogWrite(pinLeftTrackSpeed,-255);
analogWrite(pinRightTrackSpeed,-255);
     det = check();    Â
   }
   while (det == 'L') //if incoming data is a L, move wheels left
   { Â
digitalWrite(pinLeftTrackFB, LOW);
digitalWrite(pinRightTrackFB, HIGH);
digitalWrite(pinBrakeLeftTrackFB, LOW);
digitalWrite(pinBrakeRightTrackFB, LOW);
analogWrite(pinLeftTrackFB, velocity);
analogWrite(pinRightTrackFB, velocity);
analogWrite(pinLeftTrackSpeed,0);
analogWrite(pinRightTrackSpeed,255);
det = check();Â Â Â Â Â
   }Â
   while (det == 'R') //if incoming data is a R, move tank right
   { Â
digitalWrite(pinBrakeLeftTrackFB,HIGH);
digitalWrite(pinBrakeRightTrackFB,LOW);
analogWrite(pinLeftTrackFB, velocity);
analogWrite(pinRightTrackFB, velocity);
analogWrite(pinLeftTrackSpeed,255);
analogWrite(pinRightTrackSpeed,0);
det=check();
}
while (det == 'S')Â //if incoming data is a S, stop
{
digitalWrite(pinLeftTrackFB, LOW);
digitalWrite(pinRightTrackFB, LOW);
analogWrite(pinLeftTrackSpeed,0);
analogWrite(pinRightTrackSpeed,0);
det = check();
}
int check()
 if (Serial.available() > 0)  //Check for data on the serial lines.
 {Â
  dataIn = Serial.read(); //Get the character sent by the phone and store it in 'dataIn'.
    if (dataIn == 'F')
    { Â
     determinant = 'F';
    }Â
    else if (dataIn == 'B')
    {
     determinant = 'B';
    }
    else if (dataIn == 'L')Â
    {
     determinant = 'L';
    }
    else if (dataIn == 'R')Â
    {
     determinant = 'R';
    }
    else if (dataIn == 'I')Â
    {
     determinant = 'I';
    }Â
    else if (dataIn == 'J')Â
    {Â
     determinant = 'J';
    }    Â
    else if (dataIn == 'G')
    {
     determinant = 'G';
    } Â
    else if (dataIn == 'H')Â
    {
     determinant = 'H';
    }Â
    else if (dataIn == 'S')
    {
     determinant = 'S';
    }
    else if (dataIn == '0')
    {
     velocity = 0;  //"velocity" does not need to be returned.
    }
    else if (dataIn == '1')
    {
     velocity = 25;
    }
    else if (dataIn == '2')
    {
     velocity = 50;
    }
    else if (dataIn == '3')
    {
     velocity = 75;
    }
    else if (dataIn == '4')
    {
     velocity = 100;
    }
    else if (dataIn == '5')
    {
     velocity = 125;
    }
    else if (dataIn == '6')
    {
     velocity = 150;
    }
    else if (dataIn == '7')
    {
     velocity = 175;
    }
    else if (dataIn == '8')
    {
     velocity = 200;
    }
    else if (dataIn == '9')
    {
     velocity = 225;
    }
    else if (dataIn == 'q')
    {
     velocity = 255;
    }
    else if (dataIn == 'U')
    {
     determinant = 'U';
    }
    else if (dataIn == 'u')
    {
     determinant = 'u';
    }
    else if (dataIn == 'W')
    {
     determinant = 'W';
    }
  Â
    else if (dataIn == 'w')
    {
     determinant = 'w';
    }
 }
return determinant;
}


