 void loop(){
 
   meetAndroid.receive();
+  
+  getSonar();
+  
+  delay(100);
   
 }
 

 
 meetAndroid.registerFunction(forward, 'w');
 meetAndroid.registerFunction(backward, 's');
 meetAndroid.registerFunction(stopIt, 'x');
 
  pinMode(LEFTSIDE_NEG, OUTPUT);
  pinMode(LEFTSIDE_POS, OUTPUT);

  analogWrite(LEFTSIDE_POS,meetAndroid.getInt());
  analogWrite(RIGHTSIDE_POS,meetAndroid.getInt());
  analogWrite(LEFTSIDE_NEG,meetAndroid.getInt());
  analogWrite(RIGHTSIDE_NEG,meetAndroid.getInt()); 
}

void leftTurn(byte flag, byte numOfValues){
  analogWrite(LEFTSIDE_POS,0);
  analogWrite(LEFTSIDE_NEG,meetAndroid.getInt());
  analogWrite(RIGHTSIDE_POS,meetAndroid.getInt());
  analogWrite(RIGHTSIDE_NEG,0);
  Serial.print(meetAndroid.getInt());
}

void rightTurn(byte flag, byte numOfValues){
   analogWrite(LEFTSIDE_POS,meetAndroid.getInt());
   analogWrite(LEFTSIDE_NEG,0);
   analogWrite(RIGHTSIDE_POS,0);
   analogWrite(RIGHTSIDE_NEG,meetAndroid.getInt());  
}

void getSonar(){
  int duration,distance;
  
  duration = pulseIn(ECHO_PIN,HIGH);
  distance = (duration/2)/29.1;
  
  meetAndroid.send(distance);
  Serial.println(distance);
  
}




