Urgent Help Needed Please!

I am gettig error message that ‘check was not declared in the scope’. I have done privious projhect with the same code but it do not gets this error but this time it is getting an error. Today coding is

#include <AFMotor.h>

//Objects
AF_DCMotor motorRight(1, MOTOR12_64KHZ); // create motor #1, 64KHz pwm

//Constants and variable
char dataIn = 'S';
char determinant;
char det;
int vel = 255; //Bluetooth Stuff
int god = 255;
int aod = 255;
int bod = 255;
int cod = 255;
int dod = 255;

void setup() {
  Serial.begin(9600); // set up Serial library at 9600 bps
 
 //Initalization messages
  Serial.println("SAARTHI");
  Serial.println("Mr.PhotoBox");
  Serial.println("Reday for use Lets's Click it !!");
 
  pinMode(8, OUTPUT);  //1 Led
  pinMode(9, OUTPUT);  //2 Led
   pinMode(10, OUTPUT);  //3 Led
   pinMode(11, OUTPUT);  //4 Led
   pinMode(12, OUTPUT);  //5 Led
  
  
  
  //turn off motors
  motorRight.setSpeed(0);
  motorRight.run(RELEASE);
 
}

void loop() {

**>  det = check(); //call check() subrotine to get the serial code<**

And my privious codding was

#include <AFMotor.h>


//Objects
AF_DCMotor motorRight(1, MOTOR12_64KHZ); // create motor #1, 64KHz pwm
//Constants and variable
char dataIn = 'S';
char determinant;
char det;
int vel = 255; //Bluetooth Stuff


void setup() {
  Serial.begin(9600); // set up Serial library at 9600 bps
  pinMode(9, OUTPUT);  //FrontLed
  pinMode(8, OUTPUT);  //BackLed
   pinMode(10, OUTPUT);  //Horn
  
 
  //Initalization messages
  Serial.println("Mr.robot");
  Serial.println("Reday for working Run It");
  
  //turn off motors
  motorRight.setSpeed(0);
  motorRight.run(RELEASE);
}

void loop() {
  det = check(); //call check() subrotine to get the serial code

Please help me out please it’s urgent.

I am getting this issue

Please helpppppp!!!

Hi,
Welcome to the forum.

Where is the check() function.
You code looks cutoff at the bottom in both versions.
Is it the complete code?
What Arduino are you using?

Thanks… Tom… :grinning: :+1: :coffee: :australia:

I am using arduino uno R3

What to do please help

I am gettig error message that ‘check was not declared in the scope’. I have done privious projhect with the same code but it do not gets this error but this time it is getting an error. Today coding is

#include <AFMotor.h>

//Objects
AF_DCMotor motorRight(1, MOTOR12_64KHZ); // create motor #1, 64KHz pwm

//Constants and variable
char dataIn = 'S';
char determinant;
char det;
int vel = 255; //Bluetooth Stuff
int god = 255;
int aod = 255;
int bod = 255;
int cod = 255;
int dod = 255;

void setup() {
  Serial.begin(9600); // set up Serial library at 9600 bps
 
 //Initalization messages
  Serial.println("SAARTHI");
  Serial.println("Mr.PhotoBox");
  Serial.println("Reday for use Lets's Click it !!");
 
  pinMode(8, OUTPUT);  //1 Led
  pinMode(9, OUTPUT);  //2 Led
   pinMode(10, OUTPUT);  //3 Led
   pinMode(11, OUTPUT);  //4 Led
   pinMode(12, OUTPUT);  //5 Led
  
  
  
  //turn off motors
  motorRight.setSpeed(0);
  motorRight.run(RELEASE);
 
}

void loop() {

**>  det = check(); //call check() subrotine to get the serial code<**

And my privious codding was

#include <AFMotor.h>


//Objects
AF_DCMotor motorRight(1, MOTOR12_64KHZ); // create motor #1, 64KHz pwm
//Constants and variable
char dataIn = 'S';
char determinant;
char det;
int vel = 255; //Bluetooth Stuff


void setup() {
  Serial.begin(9600); // set up Serial library at 9600 bps
  pinMode(9, OUTPUT);  //FrontLed
  pinMode(8, OUTPUT);  //BackLed
   pinMode(10, OUTPUT);  //Horn
  
 
  //Initalization messages
  Serial.println("Mr.robot");
  Serial.println("Reday for working Run It");
  
  //turn off motors
  motorRight.setSpeed(0);
  motorRight.run(RELEASE);
}

void loop() {
  det = check(); //call check() subrotine to get the serial code

Please help me out please it’s urgent.

I am getting this issue

Please help it’s urgent please please please

PLEASE post the complete code.
Your code is not complete! ! !

Tom… :grinning: :+1: :coffee: :australia:

I’ve merged your cross-posts @krishna_agarwal .

Cross-posting is against the rules of the forum. The reason is that duplicate posts can waste the time of the people trying to help. Someone might spend 15 minutes (or more) writing a detailed answer on this topic, without knowing that someone else already did the same in the other topic.

Repeated cross-posting will result in a suspension from the forum.

In the future, please take some time to pick the forum board that best suits the topic of your question and then only post once to that forum board. This is basic forum etiquette, as explained in the “How to get the best out of this forum” guide you will find at the top of every forum category. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

No this is not a complete code
I had just send a short code sh

Sorry for it

But please help me

Hi,
The code you posted does not have
check() function in it.

That is what the error is telling you.

Did you write it, or are you using an edited code from another source?

Tom… :grinning: :+1: :coffee: :australia:

It was copied

Hi,
Have you got the original?

Your codes are not complete…

Tom… :grinning: :+1: :coffee: :australia:

/*
Author: Krishna Agarwal
*/

#include <AFMotor.h>

//Objects
AF_DCMotor motorRight(1, MOTOR12_64KHZ); // create motor #1, 64KHz pwm

//Constants and variable
char dataIn = ‘S’;
char determinant;
char det;
int vel = 255; //Bluetooth Stuff
int god = 255;
int aod = 255;
int bod = 255;
int cod = 255;
int dod = 255;

void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps

//Initalization messages
Serial.println(“ab”);
Serial.println(“ab”);
Serial.println(“ab”);

pinMode(8, OUTPUT); //1 Led
pinMode(9, OUTPUT); //2 Led
pinMode(10, OUTPUT); //3 Led
pinMode(11, OUTPUT); //4 Led
pinMode(12, OUTPUT); //5 Led

//turn off motors
motorRight.setSpeed(0);
motorRight.run(RELEASE);

}

void loop() {
det = check();

//serial code analysis
switch (det){
case ‘F’: // F, move forward
motorRight.setSpeed(vel);
motorRight.run(FORWARD);
det = check();
break;

case 'B': // B, move back
motorRight.setSpeed(vel);
motorRight.run(BACKWARD);      
det = check();
break;

case 'L':// L, move wheels left
motorRight.setSpeed(vel/4);
motorRight.run(FORWARD);      
det = check();
break;

case 'R': // R, move wheels right
motorRight.setSpeed(vel/2);
motorRight.run(FORWARD);     
det = check();
break;


case 'S': 

// S, stop
motorRight.setSpeed(vel);
motorRight.run(RELEASE);
det = check();
break;

 case 'G': 

// G, 1 Light On
digitalWrite(8, god);
det = check();
break;

 case 'A': 

// A, 2 Light on
digitalWrite(9, aod);
det = check();
break;

case ‘B’:
// B, 3 Light on
digitalWrite(10, bod);
det = check();
break;

 case 'C': 

// C, 4 Light On
digitalWrite(11, cod);
det = check();
break;

 case 'D': 

// D, 5 Light On
digitalWrite(12, dod);
det = check();
break;

 case 'g': 

// g, 1 Light off
digitalWrite(8, LOW);
det = check();
break;

 case 'a': 

// a, 2 Light off
digitalWrite(9, LOW);
det = check();
break;

case ‘b’:
// b, 3 Light off
digitalWrite(10, LOW);
det = check();
break;

 case 'c': 

// c, 4 Light On
digitalWrite(11, LOW);
det = check();
break;

 case 'd': 

// D, 5 Light Off
digitalWrite(12, LOW);
det = check();
break;

    case 'Z': 

// Z, All Light On
digitalWrite(8, god);
digitalWrite(9, aod);
digitalWrite(10, bod);
digitalWrite(11, cod);
digitalWrite(12, dod);
det = check();
break;

case ‘z’:
// z, All Light off
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
digitalWrite(12, LOW);
det = check();
break;

//get bluetooth code received from serial port
int check(){
if (Serial.available() > 0){// if there is valid data in the serial port
dataIn = Serial.read();// stores data into a varialbe

//check the code
if (dataIn == ‘F’){//Forward
determinant = ‘F’;
}
else if (dataIn == ‘B’){//Backward
determinant = ‘B’;
}
else if (dataIn == ‘L’){//Left
determinant = ‘L’;
}
else if (dataIn == ‘R’){//Right
determinant = ‘R’;
}
else if (dataIn == ‘S’){//Stop motor
determinant = ‘S’;
}
else if (dataIn == ‘G’){//1 Light On
determinant = ‘G’;
}
else if (dataIn == ‘A’){//2 Light On
determinant = ‘A’;
}
else if (dataIn == ‘B’){//3 Light On
determinant = ‘B’;
}
else if (dataIn == ‘C’){//4 Light On
determinant = ‘C’;
}
else if (dataIn == ‘D’){//5 Light On
determinant = ‘D’;
}
else if (dataIn == ‘g’){//1 Light Off
determinant = ‘g’;
}
else if (dataIn == ‘a’){//2 Light off
determinant = ‘a’;
}
else if (dataIn == ‘b’){//3 Light Off
determinant = ‘b’;
}
else if (dataIn == ‘c’){//4 Light Off
determinant = ‘c’;
}
else if (dataIn == ‘d’){//5 Light off
determinant = ‘d’;
}else if (dataIn == ‘Z’){//All Light On
determinant = ‘Z’;
}
else if (dataIn == ‘z’){//All light off
determinant = ‘z’;
}

else if (dataIn == '0'){//Speed 0
  vel = 0;
}
else if (dataIn == '1'){//Speed 25
  vel = 25;
}
else if (dataIn == '2'){//Speed 50
  vel = 50;
}
else if (dataIn == '3'){//Speed 75
  vel = 75;
}
else if (dataIn == '4'){//Speed 100
  vel = 100;
}
else if (dataIn == '5'){//Speed 125
  vel = 125;
}
else if (dataIn == '6'){//Speed 150
  vel = 150;
}
else if (dataIn == '7'){//Speed 175
  vel = 175;
}
else if (dataIn == '8'){//Speed 200
  vel = 200;
}
else if (dataIn == '9'){//Speed 225
  vel = 225;
}
else if (dataIn == '11'){//Led 0
  god = 0;
}   
 else if (dataIn == '12'){//Led 25
  god = 25;
}   else if (dataIn == '13'){//Led 50
  god = 50;
}   else if (dataIn == '14'){//Led 75
  god = 75;
}   else if (dataIn == '15'){//Led 100
  god = 100;
}   else if (dataIn == '16'){//Led 125
  god = 125;
}   else if (dataIn == '17'){//Led 150
  god = 150;
}   else if (dataIn == '18'){//Led 200
  god = 200;
}

else if (dataIn == ‘19’){//Led 255
god = 255;
}
}
return determinant;
}

This is the full code please help

:roll_eyes:

1 Like
 if (dataIn == '12')

Oops

Your check function is embedded in another function.
C++ doesn’t allow that.

My issue is det = check

No, your current issue is with check.
That’s easily fixed.
Not so easy to fix what I highlighted

How can i fix that?
I am unable please help🤷‍♂️

Your loop function definition should be complete before your check function definition starts.

I think also the switch in the loop function is incomplete.

Fix that first.

Please remember to use code tags when posting code