Arduino + ESP8266 Serial Monitor through code

So I'm VERY new to the Arduino and physical electronics, however, I've been programming software for a few years now.

I've been at this for hours, basically, I'm able to communicate with my ESP through the serial monitor by typing AT commands and pressing Enter. It's running on 9600 baud and I'm getting valid responses. However, I have tried just about everything I can think of, and I can't seem to get the same communication through code.

void setup() {
  // put your setup code here, to run once:

void loop() {
  // put your main code here, to run repeatedly:


What's supposed to happen is, display AT and then OK, but through code, only the AT displays. I'm not sure what I could be doing wrong. The serial monitor is set to Both NL and CR.

You cannot use the Serial monitor to display output when you also have a device attached to the Serial pins 0 and 1, which I presume you have. Try using SoftwareSerial to communicate with the device on other pins, then you can use Serial to display messages.

To talk to the ESP8266 directly you can either remove the ATmega chip from the Arduino or jumper from Reset to Ground to keep the ATmega from doing anything. Then you can connect the RX pin of the ESP8266 to the RX pin of the Arduino and the TX pin of the ESP8266 to the TX pin of the Arduino (and Ground to Ground). This will connect the ESP8266 in place of the ATmega and let you talk to it over the USB cable.

If you want to have the Arduino talk to the ESP8266 you have to swap the RX and TX pins: RX to TX and TX to RX. This will let the Arduino talk to the ESP8266 but all you will get on Serial Monitor is what is coming out of the Arduino (like you have now). You can't see the data that the ESP8266 is sending to the Arduino because that is the pin the PC sends on, not the one it receives on.