I tried to read 2 inputs from serial monitor, but it takes first input and then moves to next and sudden jump to first input without reading the second input. That means the system reads first input value only.
Please help me to correct this.
//----------------------------------------------------------------------------------
int A;
int B;
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("Please enter a value for A?")
A = Serial.read();
while (Serial.available()){
}
Serial.println("Please enter a value for B?")
B = Serial.read();
while (Serial.available()){
}
if (A>B){
//do something
}else{ if (B>A) {
//Do another thing
}
//Display some thing
}
endif
}
//-----------------------------------------------------------------------------
Thank you.