1

I am using Arduino Uno and Blue tooth HC-06, I am trying to use this in order to switch a LED through mt phone but I cannot create communication between the Bluetooth and the Arduino, I am using software version 1.8.13 and I manage to pair to the Bluetooth through my phone, this is my code:

    char data = 0;                //Variable for storing received data
    void setup() 
    {
    Serial.begin(9600);         //Sets the data rate in bits per second (baud) for serial data transmission
    pinMode(13, OUTPUT);        //Sets digital pin 13 as output pin
    }
    void loop()
    {
    if(Serial.available() > 0)  // Send data only when you receive data:
    {
    data = Serial.read();      //Read the incoming data and store it into variable data
    Serial.print(data);        //Print Value inside data in Serial monitor
    Serial.print("\n");        //New line 
    if(data == '1')            //Checks whether value of data is equal to 1 
    digitalWrite(8, HIGH);  //If value is 1 then LED turns ON
    else if(data == '0')       //Checks whether value of data is equal to 0
    digitalWrite(8, LOW);   //If value is 0 then LED turns OFF
    }    

                        

}

and this is the image of the wiring: enter image description here

I don't have any problem with the computer the software or the Arduino different codes I can run very easily the only problem is with the Bluetooth device

Thanks a lot

1
  • 1
    With what app your you trying to send the serial data? Are you using Andriod? The HC-06 will only be connected, if the app starts and holds the connection. So you cannot just connect the HC-06 just in the Andriod bluetooth settings. That is only for pairing. The actual connection is initiated by the app. Thats what I already stumbed across myself.
    – chrisl
    Commented Oct 6, 2020 at 9:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.