0

i want to know for executing "Bluetooth.available();" how much time is required, if connection is available, also in case of non availability of connection how much time is spent.

also for

Bluetooth.read() ; Bluetooth.println("LED On!");

How much time is required .

my project is time sensitive so asking . kindly help

part of my code :::::::

     #include <SoftwareSerial.h>
   SoftwareSerial Bluetooth(10, 9); // RX, TX
  int LED = 13; // the on-board LED
  int Data; // the data received

     void setup() {
      Bluetooth.begin(9600);
     Serial.begin(9600);
     Serial.println("Waiting for command...");
      Bluetooth.println("Send 1 to turn on the LED. Send 0 to turn Off");
       pinMode(LED,OUTPUT);

     }

       void loop() {
        if (Bluetooth.available()){ //wait for data received
        Data=Bluetooth.read();
         if(Data=='1'){  
        digitalWrite(LED,1);
        Serial.println("LED On!");
    Bluetooth.println("LED On!");

1 Answers1

0

how much time is required, if connection is available, also in case of non availability of connection how much time is spent.

None! available() and read() return immediately. SoftwareSerial itself burdens the controller a little bit, while data is being read or written. While sending at 9600 (which takes 1 ms per character), other things can happen in parallel, if the send buffer is not yet full. However SoftwareSerial cannot work full duplex, so while writing, nothing can be read.

datafiddler
  • 1,755
  • 3
  • 17
  • 30