How to detect a key press

The sketch you posted uses Serial.read() to get characters from the Serial Monitor, but the Serial Monitor will not send any characters until you press Return unless there is a trick that I am not aware of.

Unless there is such a trick then the sketch does not meet these requirements

There is. Press return. Otherwise use a pushbutton, like I did, to call the same function. I don't think the project in question is rocket surgery. Alternatively, change the 'x' to '\n'

@pinknami says that he/she want the Arduino to do something

not when a key followed by Return is pressed

Because of the requirement to react to one of many keys just pressing Return is not a solution, which is where I was leading when I asked

He/she did not reply when I asked

but taking the requirement literally (no use of Enter/Return) then it is not possible using the Serial Monitor but trivial using Coolterm

I still have my doubts that a PC needs to be involved at all but @pinknami has gone quiet

SUMMARY
We don't really know what @pinknami wants or needs and I suspect that neither does he/she

1 Like

You've got that right: another satisfied customer :wink:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.