Controlling CPU fan issue

Hi all,
I'm trying to control a CPU fan speed, but from some reason, I can either send 0 or 9. Nothing in between will work.
This is my code.

#define motorPin 11

void setup() {
// put your setup code here, to run once:
//Set button pin as input
pinMode(motorPin, OUTPUT);
analogWrite(motorPin, 0);
Serial.begin(9600);
Serial.println("Enter a number between 0 and 9: ");

}

void loop() {
if (Serial.available())
{

//Get an input from the user
char ch = Serial.read();

if (ch >= '0' && ch <= '9')
{
int speed = ch - '0';
analogWrite(motorPin, map(speed, 0,9,0, 255));
}
}
}

Can you please help?
(see attachments for circuit itself)