Sponge Bob
Sponge Bob

Reputation: 1621

What character represent "Enter" for serial communication?

I am trying to send a serial command using my Arduino, but I can't find out how to replicate the Enter key. I've tried \r\n as well as \n and neither of those seem to do it.

I've tried the Arduino functions Serial.write() Serial.print() Serial.println() and none of those work either.

What can I use to replicate the Enter key?

Thank you

Upvotes: 0

Views: 8499

Answers (2)

gengumby
gengumby

Reputation: 19

In general, it depends on the application that is processing the key press. From the keyboard, the typical scan code 0x1C is sent to the application for the Enter key (and 0x9C on release).

In PuTTY (related to OP's question here), it sends ASCII CR (carriage return) 0x0D only, even on Windows machines.

Upvotes: 0

unloco
unloco

Reputation: 7330

Try \r
It has the ASCII 0xD(13) and it's called Carriage Return

Upvotes: 2

Related Questions