Controlling the speed of a dc motor?

So i set up everything as that example, but with a 2k resistor, a 9v battery, a 2N3904 transistor(also an NPN so it shouldn't matter) and instead of a potentiometer for PWM I'm using a button that increases the value by 15 each time it's pushed.

Nothing happens until the value gets to 255 then it kicks on. Any thoughts that may help me?

I could post the code but I don't think that's where the problem is.