Help need in Arduino coding : Arduino with HC05



  • Plese help me to make a Arduino program to make the led blink continuously, when the hc-05 bluetooth module get disconnected from mobile.



  • 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 .


Log in to reply
 

Recent Posts

  • read more
  • Hi @Akhil I found the following answer in one of the forums. here is the link to the thread.

    The way that I've seen most people do it (have a look on the Raspberry Pi forums), and have done myself with success is using /etc/rc.local.

    All you need to do here is put ./myscript in the rc.local text file. If it's in python, put python myscript.py.

    This literally is "a simple solution, (like dropping my script in some "startup" directory or something similar)"- maybe search on the forums when you're having questions as well, this solution came up on the first 4 results of a google search!

    read more
  • i need to run a QT application on BOOT. and i want to disable all controls like minimize application, close application.
    Anyone have experience in this? please help me.
    THANKS!

    read more
  • @mubassir-mk Glad that it helped.

    read more
  • M

    @kowshik1729 Thank you....
    Very help full your replay ...

    read more