arduino and esp8266-01

Hi I was sucessfully able to control led via esp8266-01 interfaced with arduino mini pro.but weird thing i am facing here is that there is a delay in controlling led. while using gpio in esp8266 is quick. is there any program i can avoid those delays ? Thank you

is there any program i can avoid those delays ?

Yes. It obviously isn't yours though.

Post your code.

And please use the code button </> so your code looks like this and is easy to copy to a text editor

…R

PaulS:
Yes. It obviously isn’t yours though.

i am very sorry for being so mean asking the programs directly actually was freaked out with lots of program

Here is my codes

#include <SoftwareSerial.h>

#define DEBUG true 

SoftwareSerial esp8266(2,3);

void setup()
{
Serial.begin(9600);
esp8266.begin(9600);

pinMode(11,OUTPUT);
digitalWrite(11,LOW);

pinMode(12,OUTPUT);
digitalWrite(12,LOW);

pinMode(13,OUTPUT);
digitalWrite(13,LOW);

sendData("AT+RST\r\n",2000,DEBUG);
sendData("AT+CWMODE=2\r\n",1000,DEBUG);
sendData("AT+CIFSR\r\n",1000,DEBUG);
sendData("AT+CIPMUX=1\r\n",1000,DEBUG);
sendData("AT+CIPSERVER=1,80\r\n",1000,DEBUG);
}

void loop()
{
  if(esp8266.available())
  {
  if(esp8266.find("+IPD,"))
  {
    delay(500);
    
    int connectionId = esp8266.read()-48;
    
    
    esp8266.find("pin=");
    
    int pinNumber = (esp8266.read()-48)*10;
    pinNumber += (esp8266.read()-48);
    
    digitalWrite(pinNumber, !digitalRead(pinNumber));
  
  String closeCommand ="AT+CIPCLOSE=";
  closeCommand+=connectionId;
  closeCommand+="\r\n";
  
  
  sendData(closeCommand,1000,DEBUG);
  }
}
}
    
 String sendData(String command, const int timeout, boolean debug)
 {
   String response = "";
   esp8266.print(command);
   long int time = millis();
   
   while((time+timeout) > millis())
    
    {
      while(esp8266.available())
    {
      char c = esp8266.read();
      response+=c;
    }
    }
      
      if (debug)
      {
      Serial.print(response);
      }
    return response;
    
    
 }

Even though I can now see your code I can't relate it to your original question. You need to describe the symptoms more clearly.

I notice that you have delay(500); in your code. Is that necessary? Is that the cause of the problem?

The Arduino can do nothing within a delay(). If you need a non-blocking interval of 500 millisecs you should use millis() to manage the timing as illustrated in Several Things at a Time

...R

Your code is full of delay()s and blocking code. It's no wonder it is slow. Read and store data AS FAST AS IT ARRIVES, using non-blocking functions (NO find()!). Parse the data when the end of record marker arrives.

Ditch the String class.

Robin2: Even though I can now see your code I can't relate it to your original question. You need to describe the symptoms more clearly.

I notice that you have delay(500); in your code. Is that necessary? Is that the cause of the problem?

The Arduino can do nothing within a delay(). If you need a non-blocking interval of 500 millisecs you should use millis() to manage the timing as illustrated in Several Things at a Time

...R

My question is when i try to reduce delay my server got stuck in loops result in crash.so is there any way or any sketch for interfacing between arduino and esp8266 that will be quick in glowing led after sending request in url

Thanks for quick reply Robin2