Wait statement or similar function

Hi. I am new to Arduino. And hopefully this is my 1st question to Arduino forum.

I have a program where I am reading a string from the serial monitor and printing it to my LCD.

The problem is when I am printing my string, Eg,. Serial.print("enter the word"); When I read this and transfer those values to my LCD and LCD will display my input string and holds. But my serial monitor keeps on printing again and again "enter the word". I want my Arduino to print once "enter the word" then if user inputs then get those values and transfer it to an LCD. Then again only once it should ask to print not again and again. If you guys have know that any function can help me on this .. will be appreciated. And I have an another issue in printing on my LCD . Eg,. If I get the word "hello" from the user from serial monitor then when I print it on my LCD it prints hello including one unknown character next to the word hello which I don't even know what I should call for that. I am sorry for my bad English):..

It would help if you posted your program. It's not easy to tell you what should be changed in something we can't see.

See "How to use this forum - please read" at the top of this and every forum for useful information about how to ask questions and how to post code etc.

Steve

I want my Arduino to print once "enter the word"

Make the printing of the prompt dependant on a boolean variable and print it only when the boolean is false. Once you have printed the message set the boolean to true to prevent further printing

If I get the word "hello" from the user from serial monitor then when I print it on my LCD it prints hello including one unknown character next to the word hello

How exactly are you getting the input from the user ?

Please post your complete program here using code tags when you do to avoid the forum software misinterpreting parts of your code as HTML commands

UKHeliBob: Make the printing of the prompt dependant on a boolean variable and print it only when the boolean is false. Once you have printed the message set the boolean to true to prevent further printing How exactly are you getting the input from the user ?

This would not be necessary, you can put it in the serial setup(). Because the arduino goes through this only the first time. You will get only get one "enter the word" message

MrBijnens: Because the arduino goes through this only the first time.

I'm going out on a limb here, but I "think" UKHeliBob knows that... ;)

MrBijnens: This would not be necessary, you can put it in the serial setup(). Because the arduino goes through this only the first time. You will get only get one "enter the word" message

So "This would might not be necessary", since we have no idea what the rest of the sketch does and it's very possible that a one-time Serial.print() from setup() will scroll off the screen; OP may anyway want to re-ask the user at certain times under certain circumstances.

If I get the word "hello" from the user from serial monitor then when I print it on my LCD it prints hello including one unknown character next to the word hello

Are you doing an lcd.println()? The "ln" part does a line end, which lcd's can't act on and it tries to print the line end. If so, do lcd.print() with no "ln".

OP may anyway want to re-ask the user at certain times under certain circumstances.

That is what I had in mind when I suggested controlling the prompt using a boolean but as the OP has not shared his exact requirements we don't know.

Even if the requirement is to print the prompt only once I would still be inclined to put it in the loop() function as one state of a state machine because doing that allows greater flexibility perhaps to time how long it takes the user to respond, prompting again with different text to help them if nothing has been entered after a period of time, timing out the input phase if they take too long to say nothing of validating the input and providing feedback or perhaps allowing for a backdoor into the software using an administrator to enter something at the prompt.

Often what starts as a simple requirement moves to a more complicated one once the simple one is implemented and it is better to plan ahead and write the program in a flexible way that allows changes of requirements to be implemented without starting again or trying to shoehorn a change into code that is already overly complex.

Users are notoriously difficult at specifying a requirement until they actually see something and then there is the problem of dealing with deliberate or accidental entry of erroneous data.

When/if the OP makes the requirement known then there will be an opportunity to provide more context sensitive help.