Code to set a speed on the motor

code to Reads a number between 0 – 9 from the Serial monitor and sets the motor speed
between 0 and 100 respectively (in equal steps).

This is not how this forum works.

YOU provide the code, we tell you what to do if it is not working as expected.

As Wawa said, we should not write the code for you, but we can give you some tips.

Are you using a DC motor or a servo?

The serial library:

The map function to adapt the range: