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
}
}