Bluetooth Problems

Hi!

Currently trying to navigate my way through HC-06 and trying to establish a connection with Serial Monitor App.

#include <SoftwareSerial.h>
#include <Keyboard.h>
SoftwareSerial BT(10, 11); 
      
const int flexPin0 = A0; //pin A0 to read analog input
const int flexPin1 = A1; //pin A0 to read analog input
const int flexPin2 = A2; //pin A0 to read analog input
const int flexPin3 = A3; //pin A0 to read analog input

int value0; //save analog value
int value1; //save analog value
int value2; //save analog value
int value3; //save analog value
      
int a; // stores incoming character from other device
int b;
int c;
int d;
int e;
int f;
 
void setup()  
{
    Serial.begin(9600);      
    BT.begin(9600);
    BT.println("Hello from Arduino");
    pinMode(A0,INPUT_PULLUP);
    pinMode(A1,INPUT_PULLUP);
    pinMode(A2,INPUT_PULLUP);
    pinMode(A3,INPUT_PULLUP);
    Keyboard.begin();
}
  
void loop() 
{  
  
   if (BT.available())
   {
    //a=(BT.read());
  
   //while (a=='1')
   // { 
    value0 = analogRead(flexPin0);         //Read and save analog value from potentiometer
    Serial.println(value0);//Read and save analog value from potentiometer
    delay (100);
        
    value1 = analogRead(flexPin1);
    //Serial.println(value1);//Read and save analog value from potentiometee
    delay (100);
  
    value2 = analogRead(flexPin2);         //Read and save analog value from potentiometer
    //Serial.println(value2);//Read and save analog value from potentiometer
    delay (100);
        
    value3 = analogRead(flexPin3);         //Read and save analog value from potentiometer
    //Serial.println(value3);//Read and save analog value from potentiometer
    delay (100);
   

    if (analogRead(A0) >= 970)
      { 
        Keyboard.print("A");
        Keyboard.release("A");
        b=b+1;
      } else if (analogRead(A1) >= 970 )
      { 
        Keyboard.print("S");
        Keyboard.release("S");
        c=c+1;
      } else if (analogRead(A2)>= 800 )
      { 
        Keyboard.print("D");
        Keyboard.release("D");
        d=d+1;
      }else if (analogRead(A3) >= 800)
      { 
        Keyboard.print("F");
        Keyboard.release("F");
        e=e+1;
      } 

        /*f=(BT.read());
        if (f =='2')
      {
        BT.print("A:") ;  BT.println(c) ; 
        BT.print("S:") ;  BT.println(d) ;   
        BT.print("D:") ;  BT.println(e) ;   
        BT.print("F:") ;  BT.println(f) ;   

      }*/
     //}

   }
}

I closed out most of the code because I'm just trying out the HC-06. From my understanding, once the HC-06 has established a connection with the software, it will print out the values of value0. While the app says a connection has been successfully established, the serial monitor does not show any value.

Am I missing something?

From my understanding, once the HC-06 has established a connection with the software, it will print out the values of value0.

Why do you think that? Where, in your code, do you have a BT.print() call to do that?

PaulS:
Why do you think that? Where, in your code, do you have a BT.print() call to do that?

Sorry, when I said serial monitor, I meant the one with arduino (Serial.println), not the Serial Monitor app(BT.print). Apologies for not clarifying this.

Izzy13:
Sorry, when I said serial monitor, I meant the one with arduino (Serial.println), not the Serial Monitor app(BT.print). Apologies for not clarifying this.

That hardly clarifies anything.

You only use Serial.print() to output data, via the USB cable, when there is something available from the bluetooth device. What is the bluetooth device paired with?

PaulS:
You only use Serial.print() to output data, via the USB cable, when there is something available from the bluetooth device. What is the bluetooth device paired with?

Bluetooth is paired with android device via Serial Terminal.

This is a trial process, I'm trying to see if a connection is established, will the serial monitor be able to print the values. Basically I currently using the Bluetooth as sort of an 'ON OFF' button. When ON (connection establish) serial monitor should print the values.

The pairing of the bluetooth module with your phone does NOT send serial data to the Arduino. Your phone would have to send data to the bluetooth module, which would then send it to the Arduino, if it is properly connected.

PaulS:
The pairing of the bluetooth module with your phone does NOT send serial data to the Arduino. Your phone would have to send data to the bluetooth module, which would then send it to the Arduino, if it is properly connected.

#include <SoftwareSerial.h>
SoftwareSerial BT(10, 11); 
      
const int flexPin0 = A0; //pin A0 to read analog input

int value0; //save analog value
      
void setup()  
{
    Serial.begin(9600);      
    BT.begin(9600);
    pinMode(A0,INPUT_PULLUP);

}
  
void loop() 
{  
  
   if (BT.available())
   {
  
    value0 = analogRead(flexPin0);         //Read and save analog value from potentiometer
    Serial.println(value0);//Read and save analog value from potentiometer
    delay (100);
    

   }
}

The goal is not to send data from handphone to bluetooth module. I just using the bluetooth like an if condition (if BT.available, print values).

Do you have the baud rate menu of your Serial Monitor set to 9600?

The goal is not to send data from handphone to bluetooth module

The command
if (BT.available())
is listening for serial data. If you don't send any, i.e. your goal, it won't get any, and I guess that means nothing will happen.