Using Keyboard command controll unipolar stepper motor

UKHeliBob:
No surprise there as you are not printing anything to the Serial monitor in your program

Modify your program like this

void loop()

{
  static int val = 0;
  if (Serial.available() > 0)
  {
    val = Serial.read();
    Serial.print(">");
    Serial.print(val);
    Serial.println("<");
  }



What do you see on the Serial monitor ?
How many lines of output are there for each input ?
Again, what is the Line ending set to in the Serial monitor ?

For input "1" it shows "17:34:51.568 -> >49<
17:34:51.602 -> >10<" .. once only ..
For input "2" it shows "17:34:58.771 -> >50<
17:34:58.771 -> >10<"