Hi @Geethesh , Since HC05 is Interfaced with Serial (UART), you can check whether it connected or not in the Serial.available() function call.
if (Serial.available() > 0) { // Checks whether data is comming from the serial port
data = Serial.read(); // Reads the data from the serial port
}
else {
// Write what you need if serial is not connected
}
full Implementation .
#define led 13
void setup()
{
Serial.begin(9600);
pinMode(led, OUTPUT);
}
void loop()
{
if (Serial.available() > 0) { // Checks whether data is comming from the serial port
data = Serial.read(); // Reads the data from the serial port
}
else {
ledBlink();
}
}
void ledBlink()
{
digitalWrite(led, HIGH);
delay(100);
digitalWrite(led, LOW);
delay(100);
}
All the best .