Send Bit Between 2 Bluetooth HC05

Hello,

I'm new in Arduino and Bluetooth module HC05, I have problem to finish my final project, I want to send HIGH and LOW bit between 2 Bluetooth HC05 by Arduino Nano, I send HIGH and LOW bit by using delay 1ms and send it by a character. I send HIGH bit by sending character '1' and send LOW bit by sending character '0' via the Bluetooth. The problem is, when I check the bits that transferred by the master to slave using Osciloscope, the bits in the master sometimes showing HIGH 1ms and LOW 1ms and sometimes uncertain. So does the slave, even it's not showing HIGH 1ms and LOW 1ms. Please help me if you have any advice. :confused: Here's the code :

Master Code :

void setup() 
{
  Serial.begin(57600);
  BTserial.begin(38400);
  pinMode(dataserial, INPUT); 
  pinMode(bitserial, OUTPUT); 
}

void loop() 
{
digitalWrite(bitserial, LOW);      
kirimbluetooth();
digitalWrite(bitserial, HIGH);      
kirimbluetooth();
}

void kirimbluetooth()
{
 nilaiserial = digitalRead(dataserial);   
 if(nilaiserial == HIGH)                
 {
  BTserial.write('1');                    
 }
 else
 {
  BTserial.write('0');                       
 }
 delay(1);
}

Slave Code :

void setup() 
{
  Serial.begin(57600);
  BTserial.begin(38400);
  pinMode(dataserial, OUTPUT);

void loop() 
{
  if (BTserial.available() > 0)              // Checks whether data is comming from the serial port
 { 
  statusbluetooth = BTserial.read();             // Reads the data from the serial port
 }
  if (statusbluetooth == '1') 
 {
  digitalWrite(dataserial, HIGH);
 }
  else if (statusbluetooth == '0') 
 {
  digitalWrite(dataserial, LOW);
 }
 delay(1);
}

The problem is, when I check the bits that transferred by the master to slave using Osciloscope, the bits in the master sometimes showing HIGH 1ms and LOW 1ms and sometimes uncertain.

What the heck does "uncertain" mean? The o-scope shows the voltage it gets. There is NOTHING uncertain about that.

Your code won't even compile. Do NOT waste our time with code that won't compile.

adekalel:
I'm new in Arduino and Bluetooth module HC05, I have problem to finish my final project, I want to send HIGH and LOW bit between 2 Bluetooth HC05 by Arduino Nano, I send HIGH and LOW bit by using delay 1ms and send it by a character. I send HIGH bit by sending character '1' and send LOW bit by sending character '0' via the Bluetooth.

I just did something similar to this yesterday between Arduino Uno with HC-05 and a Bluetooth Terminal app on my Android smartphone.

You are not sending bits !
You are sending an ASCII character of 1 or 0.

Checking the delay on an oscilloscope is plain silly and unnecessary.

Either the 1 or 0 being sent by the Arduino is received or it isn't.

.

You are sending a byte, not a bit. And trying to send a byte every millisec may be too fast. Start by sending bytes at (say) 100 millisec intervals. That should work reliably and then you can experiment with shorter intervals if you need to.

And whatever interval you choose do NOT have any delay() in the receiver. It needs to be listening all the time.

Why do you need to send data every millisec?

...R
Serial Input Basics - simple reliable ways to receive data.

PaulS:
What the heck does "uncertain" mean? The o-scope shows the voltage it gets. There is NOTHING uncertain about that.

Your code won't even compile. Do NOT waste our time with code that won't compile.

I mean it comes random, sorry my English is not too good. Thanks

ieee488:
I just did something similar to this yesterday between Arduino Uno with HC-05 and a Bluetooth Terminal app on my Android smartphone.https://create.arduino.cc/

You are not sending bits !
You are sending an ASCII character of 1 or 0.

Checking the delay on an oscilloscope is plain silly and .

Either the 1 or 0 being sent by the Arduino is received or it isn't.

.

OK, you're right I was sending an ASCII character, I will check again, thanks