Help with serial input?

Hey guys im new to this forum and new to Arduino as a whole ( been tinkering with it for about 4weeks now but loving it so far :smiley: ) Anyways guys I need a tad bit of help with it. I’m working on a uni assignment and I’ve pretty much completed it all apart from one last little idea that came into my head.

I want to be able to enter a name into the serial monitor and for the arduino to recognize it as one word. E.g.

char name = ‘name’;

void setup(){
Serial.println(“ Enter name…”);
While(!Serial.available());
name = Serial.read();
Serial.print(“Your name”);
Serial.print(name);

Serial.println(
}
void loop (){
}

The code above is just an example of things I’ve tried for this feature but of course it doesn’t work I’ve simply added it in this post to help explain my issue.

The closest I have got is something similar to this…

Enter name...

Your name.. h Enter name...
Your name.. e Enter name...
Your name.. l Enter name...
Your name.. l Enter name...
Your name.. o Enter name...

I want the system to be able to recognize the name input as a single word so yeah that’s about it guys thank you for reading. Any help will be much appreciated. :smiley:

Maissy..

char name = 'name';

Single quotes are for single characters. Please post a picture of your keyboard with the ONE key in single quotes circled.

You might be interested in the Arduino code in this demo. It provides a reasonably comprehensive way to receive data - and without blocking other activities that may need to run at the same time.

...R

Thank you guys I ended up using the ' readBytesUntil ' function which helped me solve the problem thank you all for your help :slight_smile: