DC motor makes noise but does not rotate i am following Jeremy blum's tutorial on youtube. link i have done the exact same circuit design as he has.


but the dc motor just makes a continuous beep sound when i run this code. 

int motorPin = 9;

void setup()
{
    pinMode(motorPin, OUTPUT);
}

void loop()

{
    for(int i = 0; i &lt;= 255; i++)
    {
        analogWrite(motorPin, i);
        delay(10);
    }

    delay(500);

    for(int i = 255; i &gt;= 0; i--)
    {
        analogWrite(motorPin, i);
        delay(10);
    }

    delay(500);
}


I am clueless as to why this is happening. would be glad if someone could help me out here.
For the benefit of anyone reading Jeremy Blum's Exploring Arduino book who is having the same issue- he has labelled the transistor wrong in the book so the collector and emitter are back to front. Turn the transistor around to face the other way and your issue will be resolved.