I have a piece of code as shown, and I wish to print the value I send using serial monitor along with a message: "Writing data to slave...".
But everytime I enter a character/number in the serial monitor(like 'a' as shown), the loop runs two times instead of just once. It seems like an extra character(somewhat invisible or null) is being sent along with the typed character.
If I use the condition (Serial.available()>1) then the loop runs just once on sending one character.
Why is this so?