Urgent Help Needed Please!

I’m guessing your keyboard has a problem… particularly the } key, and the code tags…

Next, you need to rethink the large if-else block

I got rid of your errors and warnings:

/*
  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':  // DUPLICATE CASE
//      // 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  // dataIn CAN'T HOLD TWO CHARACTERS
//    {
//      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;
}

Thanks @johnwasser
it is successfully compiled and then I will upload it later thanks a lot

Why bother having "check" return a global?

it is like a short name

I have no idea what that is supposed to mean.

Can you please tell what is you meant by return a global??

You have a variable with global scope, so it is visible everywhere in your sketch ("in scope"), and yet you are returning it from your function.
I don't know why you would do that

To get the action done in a serial monitor. Like wise if I press F so it will display in serial monitor

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.