My bluetooth can not println

Hi everyone I used to bluetooth modul hc-06, but when I connected with my pc and open serial monitor does not print anything.

Here is my code.

Thank you.

#include <SoftwareSerial.h>

#include <CapacitiveSensor.h>

SoftwareSerial  myBluetooth(10,11); // RX, TX
CapacitiveSensor   cs_0_1 = CapacitiveSensor(0,1);
CapacitiveSensor   cs_2_3 = CapacitiveSensor(2,3);        // 10 megohm resistor between pins 4 & 2, pin 2 is sensor pin, add wire, foil
CapacitiveSensor   cs_4_5 = CapacitiveSensor(4,5);        // 10 megohm resistor between pins 8 & 6, pin 6 is sensor pin, add wire, foil
CapacitiveSensor   cs_6_7 = CapacitiveSensor(6,7);        // 10 megohm resistor between pins 4 & 8, pin 8 is sensor pin, add wire, foil
CapacitiveSensor   cs_8_9 = CapacitiveSensor(8,9);        // 10 megohm resistor between pins 4 & 8, pin 8 is sensor pin, add wire, foil
CapacitiveSensor   cs_A0_A1 = CapacitiveSensor(A0,A1);        // 10 megohm resistor between pins 4 & 8, pin 8 is sensor pin, add wire, foil
CapacitiveSensor   cs_12_13 = CapacitiveSensor(12,13);   

void setup()                    
{

   Serial.begin(9600);
   myBluetooth.begin(9600);
}

void loop()                    
{
    String str = "";

    
  
    long start = millis();
    long total1 =  cs_0_1.capacitiveSensor(30);
    long total2 =  cs_2_3.capacitiveSensor(30);
    long total3 =  cs_4_5.capacitiveSensor(30);
    long total4 =  cs_6_7.capacitiveSensor(30);
    long total5 =  cs_8_9.capacitiveSensor(30);
    long total6 =  cs_A0_A1.capacitiveSensor(30);
    long total7 =  cs_12_13.capacitiveSensor(30);



    if (total1 > 20)
      str.concat("1");
    else
      str.concat("0");

   
    if (total2 > 20)
      str.concat(",1");
    else
      str.concat(",0");

    if (total3 > 20)
      str.concat(",1");
    else
      str.concat(",0");

       if (total4 > 20)
      str.concat(",1");
    else
      str.concat(",0");

       if (total5 > 20)
      str.concat(",1");
    else
      str.concat(",0");
      
     if (total6 > 20)
      str.concat(",1");
     else
      str.concat(",0");

      if (total7 > 20)
      str.concat(",1");
     else
      str.concat(",0");


    str.concat(",");
    Serial.println(str);
    
  if(myBluetooth.available()){
    myBluetooth.println(str);
  }

 
   
 

    delay(100);                             // arbitrary delay to limit data to serial port 
}
}

I suggest you read a tutorial: Arduino and HC-06 (ZS-040) | Martyn Currey

.

Still same :confused:

ilayday:
Still same :confused:

Do the tutorial.

Don't use your code which obviously has FLAWS!

Understand how the module works first!

Sheesh.

if(myBluetooth.available())
{
myBluetooth.println(str);
}

What is happening here?

Do you expect to receive something from an external source via the Bluetooth Module? myBluetooth.available() method is used to check that if any character has arrived at the receiver section of the BT Module and then byte x = myBluetooth.read() instruction is executed.

It looks like that you are writing to the Module (myBluetooth.println(str)); then, why have you executed the myBluetooth.available() method?

No surprise there, bluetooth has nothing to do with printing anything. it simply relays data from Arduino to whatever it is connected to. One of the things it isn't connected to is the serial monitor, so don't expect anything interesting there. You appear to want to send data over bluetooth to the PC. You imply the PC is connected, which is probably untrue. To receive data from Bluetooth, you need to use a proper terminal programme, like RealTerm, and have that properly configured. This may be your main, and perhaps only, problem.

Your code is incomprehensible, clouded with irrelevant stuff, and all that whitespace is somewhat insulting even, but I suspect   if(myBluetooth.available()){
is redundant, and may even be the only thing wrong with it.

You might find the following background notes useful, which try to make it as simple as it can get for data logging.

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf
http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

I really think it is easier to get started with a terminal on an Android phone than a PC. It is also probably more useful.