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'