Motor not spinning

I have used this code,

int potPin = A0;
int motorPin = 9;
int potValue = 0;
int motorValue = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
potValue = analogRead(potPin);
motorValue = map(potValue, 0, 1023, 0, 255);
analogWrite(motorPin, motorValue);
Serial.print("potentiometer = " );
Serial.print(potValue);
Serial.print("t motor = ");
Serial.println(motorValue);
delay(2);
}

to try and control my motor with a potentiometer (board layout below). However i do not seem to be getting enough power to the motor to make it spin, it only whines. Any ideas of what may being going wrong? Thanks

381386.image0.jpg

According to the pic, pin 9 is not connected to the resistor.

What motor are you using? Is the Arduino able to supply enough power?

Which transistor are you using? Looking at the flat side, most (not all) are E,B,C) left to right, not what you are showing, also Arduino's 5V regulator may not be able to supply enough current.

Maybe need a smoothing cap to turn the pulse-width-modified output into a voltage?

The motor is a small 5v dc motor, i have gotten it to run before and the transistor is a 2n2222.

+Ve to Motor +, Motor - to Collector, Emitter to GND, output pin to 330 - 470 resistor to Base, if that doesn't work, try powering motor with 3 AA batts in series. Don't forget diode (stripe toward +Ve) across motor.
https://www.fairchildsemi.com/datasheets/PN/PN2222A.pdf

Had transistor & motor reversed in last post, this should work, sorry.

+Ve to Motor +, Motor - to Collector, Emitter to GND, output pin to 330 - 470 resistor to Base, if that doesn't work, try powering motor with 3 AA batts in series. Don't forget diode (stripe toward +Ve) across motor.
https://www.fairchildsemi.com/datasheets/PN/PN2222A.pdf