Click here to Skip to main content
15,888,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have to do a project about using bluetooth hc-06 and led with arduino to test the connection using bluetooth AT command only.
Main is to do a test jig for operator to test this kind of product.


i mean if led on = bluetooth connection OK
led off = bluetooth no connection
just to test this kind of product
my code is below
C++
#include <SoftwareSerial.h>
SoftwareSerial BT(10, 11); // RX | TX

 void setup() 
{
  
    Serial.begin(9600);
    Serial.println("Please Setting 'Both NL&CR' channel");
    Serial.println("Then Enter 'AT+BAUD4' first to set the Baud channel to 9600");
    Serial.println("The List of AT Comannd");
    Serial.println("      AT : Ceck the connection.");
    Serial.println(" AT+NAME : See default name");
    Serial.println(" AT+PSWD : See default password");
    Serial.println(" AT+ORGL : Restore factory settings");
    Serial.println(" AT+ADDR : See default address");
    Serial.println("Please Enter AT Command");
    Serial.println("AT");
    pinMode(13, OUTPUT);
    // HC-06 default serial speed is 9600
    BT.begin(9600);  
}

void loop()
{
 
    // Keep reading from HC-06 and send to Arduino Serial Monitor
    if (BT.available())
    {  
        Serial.write(BT.read());
    }
 
    // Keep reading from Arduino Serial Monitor and send to HC-06
    if (Serial.available())
    {
        BT.write(Serial.read());
    }
 
}
char a;
void loop1() 
{
  if (BT.available())
  // if text arrived in from BT serial...
  {
    a=(BT.read());
    
    if (a=='OK')
    {
      digitalWrite(13, HIGH);
      BT.println("LED on");
    }
    if (a==' ')
    {
      digitalWrite(13, LOW);
      BT.println("LED off");
    }
  }
}


What I have tried:

i have done using arduino serial port to show the AT command and success test the bluetooth connection but my project just need to test the bluetooth connection with one led only without pc and smartphone.
Posted
Updated 3-Aug-17 21:10pm
v2
Comments
CPallini 4-Aug-17 3:29am    
"have done using arduino serial port to show the AT command and success test the bluetooth connection but my project just need to test the bluetooth connection with one led only without pc and smartphone."
So, basically you just need to disconnect the PC...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900