ESP8266 not responding to arduino sketch

I am using ESP8266 - 01(baud rate - 115200) with Arduino Uno for my project. I interfaced ESP to Arduino Serial Monitor by uploading bare minimum code to Uno. The ESP responds to the AT commands correctly. But when trying to connect ESP with an arduino sketch it did not respond.

#include <SoftwareSerial.h>

SoftwareSerial serial(2,3);
void setup()
{
 Serial.begin(115200);
 serial.begin(115200);

 serial.println("AT\r\n");
 delay(500);
 if(serial.available() >0)
 {
    Serial.println(serial.read());
 }
 else
 {
    Serial.println("Nothing in serial buffer.");
 }
}

void loop()
{

}

For the above shown code I get the response "Nothing in serial buffer." .

Please help

Thank you all.

Try reducing the baud rate to 9600. Newer ESP8266 boards prefer the lower rate. I'm having success communicating at 9600 with Sparkfun's ESP8266 WiFi shield from an Arduino Uno.

I interfaced ESP to Arduino Serial Monitor by uploading bare minimum code to Uno.

That would indicate the baud rate is correct. How do you have the TXs and RXs connected?

The connection between Arduino Uno and ESP8266 is as shown below.

Arduino TX -> ESP TX
Arduino RX -> ESP RX

This is the connection that works with serial monitor. I tried by switching the connections as shown below but no luck in serial monitor and arduino sketch.

Arduino TX -> ESP RX
Arduino RX -> ESP TX

I am using the pinout shown at this article : ESP8266 Is Alive! | XESS Corp.

And according to that my ESP is V090.

Labspace:
The connection between Arduino Uno and ESP8266 is as shown below.

Arduino TX -> ESP TX
Arduino RX -> ESP RX

This is the connection that works with serial monitor. I tried by switching the connections as shown below but no luck in serial monitor and arduino sketch.

Arduino TX -> ESP RX
Arduino RX -> ESP TX

I am using the pinout shown at this article : http://www.xess.com/blog/esp8266-is-alive/

And according to that my ESP is V090.

This worked for me!!