title: Actual difference between Serial.parseInt() and Serial.read()?
body: <p>i am writing a simple program on working of logic gates (it is being programmed in arduino inputs are taken using serial monitor), i dont really understand the working of parseint and read ive read numerous articles online but still its not clear to me.
  here is the code</p>
  
  <pre><code>boolean a,b;
  int val;
  
  void setup(){
  Serial.begin(9600);
    Serial.setTimeout(2000);
  Serial.println("Enter what logic you want to implement: \nFor AND enter 1\n For NAND enter 2\n For OR enter 3\n For NOR enter 4\n For EX- OR enter 5\n For EX-NOR enter 6\n For NOT enter 7");
  }
  
  void loop(){
  if(Serial.available()&gt;0){
  val= Serial.read();
  if(val=='1')
  {
  //AND
  Serial.println("SELECTED AND GATE:");
  Serial.println("Enter your inputs:");
  a=Serial.parseInt(); 
  Serial.println(a); 
  b=Serial.parseInt(); 
  Serial.println(b);
  if(a &amp;&amp; b){
  Serial.print("OUTPUT:"); 
  Serial.println("1"); 
  }
  else{
  Serial.print("OUTPUT:"); 
  Serial.println("0");
  }
  }
  else if(val=='2'){
  //NAND
  Serial.println("SELECTED NAND GATE:");
  Serial.println("Enter your inputs:"); 
  a=Serial.parseInt(); 
  Serial.println(a); 
  b=Serial.parseInt(); 
  Serial.println(b);
  if(a &amp;&amp; b){
  Serial.print("OUTPUT:"); 
  Serial.println("0"); 
  } 
  else{
  Serial.print("OUTPUT:"); 
  Serial.println("1");
  }
  }
  else if(val=='3'){
  //OR
  Serial.println("SELECTED OR GATE:");
  Serial.println("Enter your inputs:");
  a=Serial.parseInt();
  Serial.println(a); 
  b=Serial.parseInt();
  Serial.println(b);
  if(a || b){
  Serial.print("OUTPUT:");
  Serial.println("1"); 
  } 
  else{
  Serial.print("OUTPUT:"); 
  Serial.println("0");
  }
  }
  else if(val=='4'){
  //NOR
  Serial.println("SELECTED NOR GATE:"); 
  Serial.println("Enter your inputs:");
  a=Serial.parseInt();
  Serial.println(a); 
  b=Serial.parseInt(); 
  Serial.println(b); 
  if(a || b){
  Serial.print("OUTPUT:"); 
  Serial.println("0"); 
  } 
  else{
  Serial.print("OUTPUT:"); 
  Serial.println("1");
  }
  }
  else if(val=='5'){
  // EX-OR
  Serial.println("SELECTED EX-OR GATE:");
  Serial.println("Enter your inputs:");
  a=Serial.parseInt(); 
  Serial.println(a);
  b=Serial.parseInt(); 
  Serial.println(b); 
  if(a == b){
  Serial.print("OUTPUT:"); Serial.println("0"); 
  } 
  else{
  Serial.print("OUTPUT:"); Serial.println("1");
  }
  }
  else if(val=='6'){
  //EX-NOR
  Serial.println("SELECTED EX-NOR GATE:");
  Serial.println("Enter your inputs:");
  a=Serial.parseInt();
  Serial.println(a); 
  b=Serial.parseInt(); 
  Serial.println(b); 
  if(a == b){
  Serial.print("OUTPUT:");
  Serial.println("1"); 
  } 
  else{
  Serial.print("OUTPUT:"); 
  Serial.println("0");
  }
  } 
  else if(val=='7'){
  //NOT
  Serial.println("SELECTED NOT GATE:");
  Serial.println("Enter your inputs:"); 
  a=Serial.parseInt(); 
  Serial.println(a); 
  if(a==1){
  Serial.print("OUTPUT:"); Serial.println("0");
  } 
  else{
  Serial.print("OUTPUT:"); Serial.println("1");
  }
  } 
  else{
  Serial.println("No gate is assigned to this number");
  }
  }
  }
  </code></pre>
  
  <p>int the code above after serial.available ive used serial.read to read the val but if i use serial.parseint it doesnt work, similarly in every gate function ive used parseint (i know it returns the integer representation of the string) and if i put serial.read it doesnt work.
  can someone please tell the difference why this happens and whats the actual diff b/w these two.</p>