not able to understand code that uses my android phones accelerometer

hi… i found i tutorial here
http://http://www.techbitar.com/bluetooth-controlled-pan-tilt-servo.html

it uses the android phones accelerometer and sends its values to the serial port with the help of HC-05 bluetooth module. however i am a little skeptical over some parts in the code:

THIS IS THE FULL ACTUAL CODE, I HAVE COMMENTED THE PARTS THAT I DO NOT UNDERSTAND:

#define START_CMD_CHAR '>'
#define END_CMD_CHAR '\n'
#define DIV_CMD_CHAR ','

#define DEBUG 1   //THIS IS A PART I DO NOT UNDERSTAND 

String inText;
float value0, value1, value2;

void setup() {
  Serial.begin(115200);
  Serial.println("\nSensoDuino 0.13 by TechBitar.com (2013).\n");
  Serial.println("Android Sensor Type No: ");
  Serial.println("1- ACCELEROMETER  (m/s^2 - X,Y,Z)");
  Serial.println("2- MAGNETIC_FIELD (uT - X,Y,Z)");
  Serial.println("3- ORIENTATION (Yaw, Pitch, Roll)");
  Serial.println("4- GYROSCOPE (rad/sec - X,Y,Z)");
  Serial.println("5- LIGHT (SI lux)");
  Serial.println("6- PRESSURE (hPa millibar)");
  Serial.println("7- DEVICE TEMPERATURE (C)");
  Serial.println("8- PROXIMITY (Centimeters or 1,0)");
  Serial.println("9- GRAVITY (m/s^2 - X,Y,Z)");
  Serial.println("10- LINEAR_ACCELERATION (m/s^2 - X,Y,Z)");
  Serial.println("11- ROTATION_VECTOR (Degrees - X,Y,Z)" );
  Serial.println("12- RELATIVE_HUMIDITY (%)");
  Serial.println("13- AMBIENT_TEMPERATURE (C)");
  Serial.println("14- MAGNETIC_FIELD_UNCALIBRATED (uT - X,Y,Z)");
  Serial.println("15- GAME_ROTATION_VECTOR (Degrees - X,Y,Z)");
  Serial.println("16- GYROSCOPE_UNCALIBRATED (rad/sec - X,Y,Z)");
  Serial.println("17- SIGNIFICANT_MOTION (1,0)");
  Serial.println("97 - AUDIO (Vol.)");
  Serial.println("98 - GPS1 (Lat., Long., Alt.)");
  Serial.println("99 - GPS2 (Bearing, Speed, Date/Time)");
  Serial.println("\n\nNOTE: IGNORE VALUES OF 99.99\n\n");
  Serial.flush();
}

void loop()
{
  Serial.flush();
  int inCommand = 0;
  int sensorType = 0;
  unsigned long logCount = 0L;

  char getChar = ' ';  

  
  if (Serial.available() < 1) return; 

   
  getChar = Serial.read();
  if (getChar != START_CMD_CHAR) return;

  //  THIS //
  sensorType = Serial.parseInt(); // read sensor type
  logCount = Serial.parseInt();  // read total logged sensor readings
  value0 = Serial.parseFloat();  // 1st sensor value
  value1 = Serial.parseFloat();  // 2rd sensor value if exists
  value2 = Serial.parseFloat();  // 3rd sensor value if exists

  if (DEBUG) {                                // THIS ALSO //
    Serial.print("Sensor type: ");
    Serial.println(sensorType);
    Serial.print("Sensor log#: ");
    Serial.println(logCount);
    Serial.print("Val[0]: ");
    Serial.println(value0);
    Serial.print("Val[1]: ");
    Serial.println(value1);
    Serial.print("Val[2]: ");
    Serial.println(value2);
    Serial.println("-----------------------");
    delay(10);
  }
}

in short i am facing problem with #define DEBUG . Can anyone explain why are we using it in this program.

How does arduino recognise the sensor type?

Read the code, and every time (after the #define DEBUG 1), you see the word DEBUG, replace it with 1.

Basically it is so you can remove all those debugging prints by just changing that one define from 1 to 0. You don't have to go delete them and if you want them back later you can just change it back to a 1 instead of having to rewrite all of that debugging code.

if (DEBUG) {....

becomes

if (1) {.....

and

1 = true, 0 = false

so

DEBUG being set at 1 means all that Serial.print stuff happens, to help you see what values are being seen.

'if' statements only execute the following stuff inside {...} if the condition inside the () is true.

Would have been smarter to use #if so that code wasn't compiled if not needed.

And the Arduino doesn't know anything about the device that's sending the info. It doesn't know sensor type. It doesn't know phone model. It doesn't know color of the case. For example, the Arduino would have no way of knowing whether it is getting a 1 or 0 from a button, or from a lemur holding two ends of a wire and touching them together.

All the Arduino is getting over serial via BT is a bunch of binary data that is the output from those sensors that needs to be sorted out by the Arduino code to display it in a sensible manner.

so can i replace it with

int SITUATUION = 1;
while(SITUATUION  == 1){
//execute code //
}

INTP: if (DEBUG) {....

becomes

if (1) {.....

and

1 = true, 0 = false

so

DEBUG being set at 1 means all that Serial.print stuff happens, to help you see what values are being seen.

'if' statements only execute the following stuff inside {...} if the condition inside the () is true.

Just change

#define DEBUG 1   //THIS IS A PART I DO NOT UNDERSTAND

to

#define DEBUG 0   //Turn off debug functions

You can do the kind of thing you did with the "situation" variable, but I don't see why you would replace the debug switch with it. The difference with that method is that it results in compiled code.