Bluetooth to modify sketch on the run BlueSMiRF programing

hey everyone im not sure if this is possible or not??? what im trying to acheive is to adjust my Kp, Ki, Kd variables in my pid equation with my bluetooth device (Bluetooth Mate Silver - WRL-10393 - SparkFun Electronics) .
I have the device working with out a problem here is the code ive been mucking around with just to test it out

if anyone has any tips or knows if this is possible let me know i would greatly appreciate it

char value;
char KP;
char KD;
char KI;
int power=9;


void setup()
{
  Serial.begin (115200);
  pinMode (power,OUTPUT);
  digitalWrite (power,HIGH);
}

void loop() {
String val = "";
String kp ="";
String kd ="";
String ki ="";

  while (Serial.available() ) {
      value=Serial.read(); 
    val += value ;     
      
      if( val != "" && (val[0] == 'P' || val[0] == 'p') ) {   
      KP= Serial.read ();
      kp =KP;
      if (kp>0){
        Serial.print ("kp=");
        Serial.println (Serial.read ());
      }}
       if( val != "" && (val[0] == 'D' || val[0] == 'd') ) {   
      KD= Serial.read ();
      kd =KD;
      if (kd>0){
        Serial.print ("KD=");
        Serial.println (Serial.read ());
      }}
        if( val != "" && (val[0] == 'I' || val[0] == 'i') ) {   
      KI= Serial.read ();
      ki =KI;
      if (ki>0){
        Serial.print ("ki=");
        Serial.println (Serial.read ());
      }}}}
  while (Serial.available() ) {
      value=Serial.read(); 
    val += value ;     
      
      if( val != "" && (val[0] == 'P' || val[0] == 'p') ) {   
      KP= Serial.read ();
      kp =KP;
      if (kp>0){
        Serial.print ("kp=");
        Serial.println (Serial.read ());
      }}
       if( val != "" && (val[0] == 'D' || val[0] == 'd') ) {   
      KD= Serial.read ();
      kd =KD;
      if (kd>0){
        Serial.print ("KD=");
        Serial.println (Serial.read ());
      }}
        if( val != "" && (val[0] == 'I' || val[0] == 'i') ) {   
      KI= Serial.read ();
      ki =KI;
      if (ki>0){
        Serial.print ("ki=");
        Serial.println (Serial.read ());
      }}}}

So, a byte shows up in the serial buffer. Let's say it's a P. You read that character, and the next two (non-existent) characters. You store one of the characters in KP and kp, and print it. You only print the other character.

Do you not see the flaw in this logic?

What is the purpose of appending the first character (in value) to val? val never gets referenced again.

      }}}}

Lovely. Sure makes program structure easy to see.

what im trying to acheive is to adjust my Kp, Ki, Kd variables in my pid equation

What pid equation?

yea my code was a bit messy lol it was getting late when i was mucking around trying to get it to work,it needed a lot of cleaning up. as stated in my first post this was just a quick code to test out the Bluetooth before adding it to my main code, that's why there is no pid formula in then code.

"Val "gets referenced in every "if" statement in the code , it is important to have it in there.

i got it working well enough for what i want to do for anyone interested the code it is below.The purpose of the code is just to increase or decrease the variables KP, KD, KI. the code works as follows when it
receives upper case 'P' it increases KP by 0.01
receives lower case 'p' it decreases KP by 0.01
this same rule applies with KI and KD .This was simply implemented to eliminate the need for a pot or reconnecting the usb cable when tuning .

char value;
float KP;
float KD;
float KI;
int power=9;


void setup()
{
  Serial.begin (115200);
  pinMode (power,OUTPUT);
  digitalWrite (power,HIGH);
}

void loop() {
String val = "";

  while (Serial.available() ) {
      value=Serial.read(); 
    val += value ;     
      
      if( val != "" && (val[0] == 'P') ) {   
        Serial.print ("kp=");
        KP+=0.01;
        Serial.println (KP);
      }
     if( val != "" && (val[0] == 'p' ) ) {   
        Serial.print ("kp=");
        KP-=0.01;
        Serial.println (KP);
      }
    
       if( val != "" && (val[0] == 'D') ) {   
        Serial.print ("kp=");
        KD+=0.01;
        Serial.println (KD);
      }
        if( val != "" && (val[0] == 'd') ) {   
        Serial.print ("kp=");
        KD-=0.01;
        Serial.println (KD);
      }

        if( val != "" && (val[0] == 'I') ) {   
        Serial.print ("ki=");
        KI+=0.001;
        Serial.println (KI);
    }    
       if( val != "" && (val[0] == 'i') ) {   
        Serial.print ("ki=");
        KI-=0.001;
        Serial.println (KI);
    }  
  }
}

This was simply implemented to eliminate the need for a pot or reconnecting the usb cable when tuning .

So, how are you going to get serial data to the Arduino without the USB cable?