// **heres my code to the simple answering machine. the concept is i want the code to first tell me that the bot is ready to chat. After that id simply send any character as an input on the serial monitor so that it can give the response " yes " irrespective of what the input message was. The problem im facing right now is when i send an input character the output ends up being a repeating "yes" instead of a single one. Am i making any mistakes here or is my board not flushing the serial buffer properly?
**//
bool mail;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); // set baud rate
Serial.println(" Robobot is ready to chat"); // allow for the user to acknowledge the system is on
}
void loop() {
mail = Serial.available() // check if a message came
if( mail == LOW); // if mail is low do nothing, if there was a message present (Serial.available) then print "yes "
else {
delay(1000); // add some delay so the message "yes" doesnt arrive immediately
Serial.println("Yes");
mail = LOW // set mail back to LOW
word flush(); // clear the serial buffer
}
}