Hello,
This the sketch:
<
int number;
void setup() {
Serial.begin(9600);
}
void loop()
{
number=0;
Serial.flush();
while(Serial.available()==0)
{
//do nothing
}
while(Serial.available()>0)
{
number=Serial.read()-'0';
}
Serial.print("You entered: ");
Serial.println(number);
Serial.print(number);
Serial.print(" multiplied by two is ");
number=number*2;
Serial.println(number);
}
The sketch asks to enter an integer in the Serial Monitor and it responds with this:
You entered: 5
5 multiplied by two is 10
You entered: -38
-38 multiplied by two is -76
Why there seems to be a second entry (hanging in the buffer?)? I attempted multiple fixes (not that I have a lot of them in my sleeves) and nothing worked.
I appreciate any suggestions.
Thanks