user22907: I bought a ESP 8266 & I am able to send AT commands and receive response via serial monitor when I upload a empty sketch. I changed the baud rate from 115200 to 9600 by using AT+CIOBAUD=9600 and am able to run AT commands at 9600 baud rate.
Empty Sketch:
void setup() 
{

}
void loop() 
{

}

Here is how my circuit looks:

Problem
The problem is when I create a custom sketch to run AT commands it doesn't work. Here is how my sketch looks:
#include <SoftwareSerial.h>
SoftwareSerial esp8266(0,1); //RX,TX

void setup()
{

  Serial.begin(9600);
  esp8266.begin(9600); 

  Serial.println("Run AT Command");

   esp8266.print("AT\r\n");



}

void loop(){
   String response = "";
   while(esp8266.available())     {
        char c = esp8266.read(); 
        response+=c;
        Serial.print(c);
      }  

      if(response != ""){
        Serial.println(response);
      }

}

ESP8266 is receiving 3.3V but I have read TX and RX sends 5V, and they also need to be 3.3V. Don't know if thats what is causing it, but I am able to run AT commands on empty sketch, so this is a bit weird.

UPDATE:

My sketch is:
#include <SoftwareSerial.h>
SoftwareSerial esp8266(2, 3); //RX,TX

void setup()
{

  Serial.begin(9600);
  esp8266.begin(9600);


  esp8266.print("AT\r\n");



}

void loop() {
  String response = "";
  while (esp8266.available())     {
    char c = esp8266.read();
    response += c;
  }

    if (response != "") {
      Serial.println("Response: " + response);
    }



}

Serial Monitor shows this:
Response: A
Response: T


OK
Response: 

OUTPUT when I run AT+CIFSR command:
Response: A
Response: T+CIFSR


Response: 
+CIFSR:APIP
Response: ,"192.168.4.1
Response: "
+CIFSR:APMA
Response: C,"5e:cf:7f:80
Response: :f7:74"

OK

Question now is: How do I store the string being returned from the esp8266. I thought my response string was suppose to store the "OK" but that did not happen.

user33074: Just check if this answer helps. 
Here is the thing, For AT commands from serial monitor, RX or arduino should be connected to RX of ESP and TX of arduino to TX of ESP. That is the reason you are able to enter AT commands with your circuit when empty program is uploaded.
Now for arduino to communicate with ESP using program, you have to connect RX of arduino to TX of ESP and TX of Arduino to RX of ESP. In your case if using software serial 2 & 3, then pin2 to TX of Esp and pin3 to RX of ESP.
To read "OK" from ESP, try below code:
if(esp8266.find("OK"))

Also you may try this code to read:
esp8266.find("pin="); //this acts like a pointer. 
int value = esp8266.read(); //returns ASCII Code. this will read value which comes after pin=

Refer : https://www.arduino.cc/en/Serial/read

user612: Of course you cannot use the same pins for both hardware and software serial, but that part seems to have been solved in comments.

Question now is: How do I store the string being returned from the esp8266. I thought my response string was suppose to store the "OK" but that did not happen.

 while (esp8266.available())     {
    char c = esp8266.read();
    response += c;
 }

This will only read as long as characters are available, but the ATmega is able to run this loop much more quickly than characters are received, so unless the entire message was previously transferred it will likely only get a character or two before the receive buffer is found (temporarily) empty and it terminates.
You should instead read until a terminating condition is found, such as a newline character.  For safety you might also put in a "give up and try again" timeout, but make it long.
Some would try to solve this problem by inserting short delays before trying to read, but that is unwise - depending on delays creates unreliability as the necessary delay can easily change due to conditions that may on the surface seem to have little relevance, for example the esp866 might respond more slowly if it is seeing a lot of broadcast traffic on a network, or if the firmware version changes.

user22924: There is another technique that you can use, instead of hanging around waiting for more characters from the ESP8266. Your code starts:
void loop() {
    String response = "";
    while (esp8266.available())     {
        char c = esp8266.read();
        response += c;
    } // while

This has the effect of creating a new String every time loop() is entered, and you accumulate the data from the ESP8266 in that - but it's lost if you leave loop(). So it may be better to do it differently:
const char EOL = '\n'; // End of line
String response = ""; // Create String once, outside loop()

void loop() {
    char c = '\0'; // Initialise to NUL
    while (esp8266.available() && c!=EOL) { // Wait for End of Line
        c = esp8266.read();
        response += c;
    } // while
    if (c==EOL) {
        Serial.print("Response: "); // Don't use '+' if you can help it!!!
        Serial.println(response);
        // Do other processing
        response = ""; // Clear response for next string
    } // if

This has three effects:

It keeps an incomplete response between calls to loop().
It only processes response once the end-of-line is read.
It keeps loop() running nicely (important on other Arduino), rather than hanging around


22907: <p>I bought a ESP 8266 &amp; I am able to send AT commands and receive response via serial monitor when I upload a empty sketch. I changed the baud rate from 115200 to 9600 by using <code>AT+CIOBAUD=9600</code> and am able to run AT commands at 9600 baud rate.</p>

<p><strong>Empty Sketch:</strong></p>

<pre><code>void setup() 
{

}
void loop() 
{

}
</code></pre>

<p>Here is how my circuit looks:
<a href="https://i.stack.imgur.com/Ec228.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ec228.png" alt="Diagram"></a></p>

<p><strong>Problem</strong></p>

<p>The problem is when I create a custom sketch to run AT commands it doesn't work. Here is how my sketch looks:</p>

<pre><code>#include &lt;SoftwareSerial.h&gt;
SoftwareSerial esp8266(0,1); //RX,TX

void setup()
{

  Serial.begin(9600);
  esp8266.begin(9600); 

  Serial.println("Run AT Command");

   esp8266.print("AT\r\n");



}

void loop(){
   String response = "";
   while(esp8266.available())     {
        char c = esp8266.read(); 
        response+=c;
        Serial.print(c);
      }  

      if(response != ""){
        Serial.println(response);
      }

}
</code></pre>

<p>ESP8266 is receiving 3.3V but I have read TX and RX sends 5V, and they also need to be 3.3V. Don't know if thats what is causing it, but I am able to run AT commands on empty sketch, so this is a bit weird.</p>

<blockquote>
  <p>UPDATE:</p>
</blockquote>

<p><strong>My sketch is:</strong></p>

<pre><code>#include &lt;SoftwareSerial.h&gt;
SoftwareSerial esp8266(2, 3); //RX,TX

void setup()
{

  Serial.begin(9600);
  esp8266.begin(9600);


  esp8266.print("AT\r\n");



}

void loop() {
  String response = "";
  while (esp8266.available())     {
    char c = esp8266.read();
    response += c;
  }

    if (response != "") {
      Serial.println("Response: " + response);
    }



}
</code></pre>

<p><strong>Serial Monitor shows this:</strong></p>

<pre><code>Response: A
Response: T


OK
Response: 
</code></pre>

<p><strong>OUTPUT when I run AT+CIFSR command:</strong></p>

<pre><code>Response: A
Response: T+CIFSR


Response: 
+CIFSR:APIP
Response: ,"192.168.4.1
Response: "
+CIFSR:APMA
Response: C,"5e:cf:7f:80
Response: :f7:74"

OK
</code></pre>

<p><strong>Question now is:</strong> How do I store the string being returned from the esp8266. I thought my response string was suppose to store the "OK" but that did not happen.</p>
 33074: <p>Just check if this answer helps. 
Here is the thing, For AT commands from serial monitor, RX or arduino should be connected to RX of ESP and TX of arduino to TX of ESP. That is the reason you are able to enter AT commands with your circuit when empty program is uploaded.</p>

<p>Now for arduino to communicate with ESP using program, you have to connect RX of arduino to TX of ESP and TX of Arduino to RX of ESP. In your case if using software serial 2 &amp; 3, then pin2 to TX of Esp and pin3 to RX of ESP.</p>

<p>To read "OK" from ESP, try below code:</p>

<pre><code>if(esp8266.find("OK"))
</code></pre>

<p>Also you may try this code to read:</p>

<pre><code>esp8266.find("pin="); //this acts like a pointer. 
int value = esp8266.read(); //returns ASCII Code. this will read value which comes after pin=
</code></pre>

<p>Refer : <a href="https://www.arduino.cc/en/Serial/read" rel="nofollow noreferrer">https://www.arduino.cc/en/Serial/read</a></p>
 612: <p>Of course you cannot use the same pins for both hardware and software serial, but that part seems to have been solved in comments.</p>

<blockquote>
  <p>Question now is: How do I store the string being returned from the esp8266. I thought my response string was suppose to store the "OK" but that did not happen.</p>
</blockquote>

<pre><code> while (esp8266.available())     {
    char c = esp8266.read();
    response += c;
 }
</code></pre>

<p>This will only read as long as characters are available, but the ATmega is able to run this loop much more quickly than characters are received, so unless the entire message was previously transferred it will likely only get a character or two before the receive buffer is found (temporarily) empty and it terminates.</p>

<p>You should instead read until a terminating condition is found, such as a newline character.  For safety you might also put in a "give up and try again" timeout, but make it long.</p>

<p>Some would try to solve this problem by inserting short delays before trying to read, but that is unwise - depending on delays creates unreliability as the necessary delay can easily change due to conditions that may on the surface seem to have little relevance, for example the esp866 might respond more slowly if it is seeing a lot of broadcast traffic on a network, or if the firmware version changes.</p>
 22924: <p>There is another technique that you can use, instead of hanging around waiting for more characters from the ESP8266. Your code starts:</p>

<pre><code>void loop() {
    String response = "";
    while (esp8266.available())     {
        char c = esp8266.read();
        response += c;
    } // while
</code></pre>

<p>This has the effect of creating a new <code>String</code> every time <code>loop()</code> is entered, and you accumulate the data from the ESP8266 in that - but it's lost if you leave <code>loop()</code>. So it may be better to do it differently:</p>

<pre><code>const char EOL = '\n'; // End of line
String response = ""; // Create String once, outside loop()

void loop() {
    char c = '\0'; // Initialise to NUL
    while (esp8266.available() &amp;&amp; c!=EOL) { // Wait for End of Line
        c = esp8266.read();
        response += c;
    } // while
    if (c==EOL) {
        Serial.print("Response: "); // Don't use '+' if you can help it!!!
        Serial.println(response);
        // Do other processing
        response = ""; // Clear response for next string
    } // if
</code></pre>

<p>This has three effects:</p>

<ol>
<li>It keeps an incomplete <code>response</code> between calls to <code>loop()</code>.</li>
<li>It only processes <code>response</code> once the end-of-line is read.</li>
<li>It keeps <code>loop()</code> running nicely (important on other Arduino), rather than hanging around</li>
</ol>
