Simple Serial 2 Sketch:

/*
SimpleSerial

This is a little sketch that just grabs data from the serial monitor
and tells you what it got. Gives me a simple space to try to understand
what happens in the setup and loop parts...

The mental model I'm using is that there is a 'mailbox' on the serial
monitor that gets checked each time the Serial.available call is run. If
no mail Serial.available returns a 0 and if there is 'mail' then it returns
a 1. This return value is tested in some sort of conditional statement that
preceeds the Serial.read which 'opens' the mail.

To test my understanding I enter various characters into the serial monitor
input line and watch when and how the sketch responds. This helped develop my
understanding...serialData is a future project to figure out how to input
numerical data into the sketch through the serial monitor.

SimpleSerial2
This version replaces the if(Serial.available()) loop with while(! Serial.available())
loop to make the sketch pause and wait for input instead of running ahead.

Bruce Emerson 10/21/17
*/

int serialData = 0; // I want to explore inputing a # for a pinout
char chRead = 'n'; // my choice of name for the input from serial monitor

void setup()
{
Serial.begin(9600);
while (! Serial);
Serial.println("Anytime you want to enter data type 'Y' or 'y' into monitor");
}

void loop()
{
Serial.print("Top of loop: chRead: "); // Lets me know when I hit top of loop
Serial.println(chRead); // tracks chRead value
while (! Serial.available()){ // this a way of stalling the code until
delay(10); // somthing shows up in the 'mailbox'
}
Serial.println("dropped through while() loop: "); // Shouldn't show up until after input
delay (2000); // pause so I can notice
chRead = Serial.read(); // read data in 'mailbox'
if (chRead == 'Y' || chRead == 'y'){ // goes on to print if Y OR y
Serial.print("chRead: ");
Serial.print(chRead);
Serial.print(" -- ");
Serial.println(serialData);
delay (2000); // pause so I can notice
}
Serial.println("below 'if' loop");
delay(2000);

}