Skip to main content
added 32 characters in body
Source Link
jfpoilpret
  • 9.2k
  • 7
  • 38
  • 54

I am trying to both send and receive data using bluetooth module.

Receiving data works fine with this code:

void setup()  { 
    Serial1.begin(9600);
    Serial.begin(9600);
} 

void loop()  { 
    if (Serial1.available()) {
        Serial.println(Serial1.read());
    }

    delay(20);                          
}

But I cannot send any data. This is what I am doing:

void loop()  { 
    if (Serial1.available()) {
       Serial.println(Serial1.read());
    }

    delay(20);

    if (digitalRead(bluetoothInput) == HIGH) {
        Serial1.write("2");
        // only "send" prints. Nothing in android terminal
        Serial.println("send!");
        delay(1000);
    }

    delay(20);                            
}

What am I doing wrong?

I am using Arduino Leonardo and Bluetooth terminal app on androidAndroid device.

I am trying to both send and receive data using bluetooth module.

Receiving data works fine with this code:

void setup()  { 
  Serial1.begin(9600);
  Serial.begin(9600);
} 

void loop()  { 
   if (Serial1.available()){
       Serial.println(Serial1.read());
   }

  delay(20);                          
}

But I cannot send any data. This is what I am doing:

void loop()  { 
   if (Serial1.available()){
       Serial.println(Serial1.read());
   }

  delay(20);

  if(digitalRead(bluetoothInput) == HIGH) {
    Serial1.write("2");
    // only "send" prints. Nothing in android terminal
    Serial.println("send!");
    delay(1000);
  }

   delay(20);                            
}

What am I doing wrong?

I am using Arduino Leonardo and Bluetooth terminal app on android device.

I am trying to both send and receive data using bluetooth module.

Receiving data works fine with this code:

void setup() { 
    Serial1.begin(9600);
    Serial.begin(9600);
} 

void loop() { 
    if (Serial1.available()) {
        Serial.println(Serial1.read());
    }

    delay(20);                          
}

But I cannot send any data. This is what I am doing:

void loop() { 
    if (Serial1.available()) {
       Serial.println(Serial1.read());
    }

    delay(20);

    if (digitalRead(bluetoothInput) == HIGH) {
        Serial1.write("2");
        // only "send" prints. Nothing in android terminal
        Serial.println("send!");
        delay(1000);
    }

    delay(20);                            
}

What am I doing wrong?

I am using Arduino Leonardo and Bluetooth terminal app on Android device.

edited tags
Link
Source Link

Sending data via bluetooth

I am trying to both send and receive data using bluetooth module.

Receiving data works fine with this code:

void setup()  { 
  Serial1.begin(9600);
  Serial.begin(9600);
} 

void loop()  { 
   if (Serial1.available()){
       Serial.println(Serial1.read());
   }

  delay(20);                          
}

But I cannot send any data. This is what I am doing:

void loop()  { 
   if (Serial1.available()){
       Serial.println(Serial1.read());
   }

  delay(20);

  if(digitalRead(bluetoothInput) == HIGH) {
    Serial1.write("2");
    // only "send" prints. Nothing in android terminal
    Serial.println("send!");
    delay(1000);
  }

   delay(20);                            
}

What am I doing wrong?

I am using Arduino Leonardo and Bluetooth terminal app on android device.