Garbage value when connected to bluetooth

Hi friends

Please help me here i was interfacing bluetooth module hc-05 with arduino uno. I am sending a character from bt serial interface app.Once i connect this app to hc-05 before sending a character it is sending junk values. In this i am controlling an led. Before sending a character to make led on,the led will become on without receiving a character why it so.

Thanks

I can see no problem in the code that you have not posted.

Here is the code
/Executable code for the remote receiving/
int count=0;
int t15=0,t30=0,t45=0;

void setup(){
Serial.begin(9600);
pinMode(13, OUTPUT);
cli();//stop interrupts

//set timer1 interrupt at 1Hz
TCCR1A = 0;// set entire TCCR1A register to 0
TCCR1B = 0;// same for TCCR1B
TCNT1 = 0;//initialize counter value to 0
// set compare match register for 1hz increments
OCR1A = 15624;// = (1610^6) / (11024) - 1 (must be <65536)
// OCR1A = 7812;
// turn on CTC mode
TCCR1B |= (1 << WGM12);
// Set CS12 and CS10 bits for 1024 prescaler
TCCR1B |= (1 << CS12) | (1 << CS10);
// enable timer compare interrupt
TIMSK1 |= (1 << OCIE1A);

sei();//allow interrupts

}//end setup

ISR(TIMER1_COMPA_vect)
{
int blueToothVal;

count=count+1;
if(count==32000)
{
count=0;
}

Serial.println(blueToothVal);
if(Serial.available())//if there is data being recieved
{
blueToothVal=Serial.read(); //read it
}

Serial.print("bluetoothval:");
Serial.println(blueToothVal);

if(blueToothVal=='a')//if value from bluetooth serial is n

{

digitalWrite(13,HIGH); //switch on LED
Serial.println(F("Relay3 is on")); //print LED is on
Serial.print("count1:");
Serial.println(count);
t15=count;
}
Serial.print("count2:");
Serial.println(count);

if(count==(t15+10))//here 10 is used for ten second duration we can change the value for required time
{
Serial.print("count3:");
Serial.println(count);
if(digitalRead(13))
{
digitalWrite(13,LOW);
Serial.println(F("Relay3 is OFF"));
t15=0;
}
}

if(blueToothVal=='b')//if value from bluetooth serial is n
{
digitalWrite(13,HIGH); //switch on LED
Serial.println(F("Relay31 is on")); //print LED is on
Serial.print("count4:");
Serial.println(count);
t30=count;
}
if(count==(t30+20))
{
Serial.print("count5:");
Serial.println(count);
if(digitalRead(13))
{
digitalWrite(13,LOW);
Serial.println(F("Relay31 is OFF"));
t30=0;
}
}

if(blueToothVal=='c')//if value from bluetooth serial is n
{
digitalWrite(13,HIGH); //switch on LED
Serial.println(F("Relay32 is on")); //print LED is on
Serial.print("count6:");
Serial.println(count);
t45=count;
}
if(count==(t45+30))
{
Serial.print("count7:");
Serial.println(count);
if(digitalRead(13))
{
digitalWrite(13,LOW);
Serial.println(F("Relay32 is OFF"));
t45=0;
}
}
}

void loop(){

}

I've seen this already - this is a cross-post?

if(Serial.available())//if there is data being recieved
  {
   blueToothVal=Serial.read(); //read it
  }   <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< NOT HERE!

  Serial.print("bluetoothval:");
  Serial.println(blueToothVal);

  if(blueToothVal=='a')//if value from bluetooth serial is n

As I said previously this code is incorrect.

why the led is turned on before sending a character.According to code it should not happen ON right.

Some questions

  Serial.println(blueToothVal);
  if (Serial.available()) //if there is data being recieved
  {
    blueToothVal = Serial.read(); //read it
  }

Why are you unconditionally printing blueToothVal, not just once either ?

Why does the ISR contain so much code ? ISRs are intended to be sort, sharp routines that do as little as possible, maybe just setting a flag that is acted upon in loop()

Is it OK to use Serial.print() in an ISR when I believe that interrupts, used by Serial.print(), are disabled automatically when entering an ISR.