Motor not spinning, but LED blinking

Hi all,

Im really new to Arduino and electronic stuff in general but Im having a lot of trouble with getting a DC motor to spin. I can't figure out what the problem is.
I have connected the arduino board to a motor using a transistor resulting in the motor not moving. when I replace the motor for an LED it flashes (my code is for a motor to go on for 2sec then of for 2 sec).

The motor I am using is:
http://proto-pic.co.uk/hobby-motor/
The transistor I am using:
2N3604 (this has been replaced for BUF742 and BD135 with approx same result)
Diode used is:
1N4001
Resistor used:
10kOhm

The code I used is:

int motorPin = 6;

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

void loop(){

digitalWrite(motorPin, HIGH);
delay(2000);
digitalWrite(motorPin, LOW);
delay(2000);

}

attached is the schematic of my layout

any help as to why my motor wont run is appreciated.

"The motor has an operating voltage range of 1.5 to 4.5VDC and a no load speed of 12800 RPM (@4.5VDC, 320mA). "

With 10K base resistor, you are getting very little current flow thru the transistor.

Try something much smaller - like 220 ohm.

CrossRoads:
With 10K base resistor, you are getting very little current flow thru the transistor.

Thanks I changed it for a 330ohm one worked a lot better.

Does that mean that the lower the resistor value the better it will work?
Cause Im a bit confused now as to how much current we are actually suppose to send through to the transistor

You need to send in enough current into the Base to allow the collector-emitter path to go into saturation; that is, to be turned full on.
One way to do that is put as much current into the base as the arduino can live with.
The voltage across the base-emitter junction is usually about 1 diode drop, or 0.7V.
The arduino can put out 20mA pretty safely. A resistor in series from arduino to base limits the current.
With arduino pin at 5v and base at 0.7V, there is 4.3V across the resistor.
Using ohm's law, V=IR, or V/I = R, we can determine the resistor value:
(5V-0.7V)/20mA = 215 ohm
If your transistor has a gain (Hfe) of 50, then 20mA into the base will allow 1000mA thru the collector/emitter.
If the device you are driving has some resistance/impedance, like a motor, then that becomes the current limiting factor, and not the transistor, which is the situation you want when using a transistor as a switch.

CrossRoads:
Using ohm's law, V=IR, or V/I = R, we can determine the resistor value:
(5V-0.7V)/20mA = 215 ohm

so if I understand this right that means that with a 330 ohm less current is allowed to pass through but the voltage remains the same?

CrossRoads:
If your transistor has a gain (Hfe) of 50, then 20mA into the base will allow 1000mA thru the collector/emitter.

If the device you are driving has some resistance/impedance, like a motor, then that becomes the current limiting factor, and not the transistor, which is the situation you want when using a transistor as a switch.

So what I did was to connect a battery between the motor and the ground port (4x1.5V=6V) just to see if there would be more motor action. But there isnt that much change tbh. So I guess my question is, is it because Im using a 330ohm resistor for my base? does increasing the battery voltage not in anyway compensate ?

PS Ive added the new schematic, arduino board is connected to computer via usb

Wiring looks good.

You can try going lower. No more less than 120 ohms tho.
120 will allow around 35mA. 330 less. 10k, way less!

With a meter you can measure the voltage across the motor when the pin is high - should be only a tad less than the
voltage across the battery terminals.

BTW you should avoid connecting different parts of your motor circuit to different GND pins on the Arduino -
that sends motor current across the board and the header sockets. Much more reliable to build the motor
circuit separately, then join the base resistor and emitter to GND and the output pin - only one low-current
ground pin connection needed then. (I'm inferring how you've wired it from the drawing).

hhmm my problem it's same with topic, but can a motor stop and run using these program ??? i've try with these program but motor can't stop =(

Show us your wiring and provide the part numbers used. You are likely miswired, or mis-controlled.

wiring and program are same like him....my motor not spinning but i put LED in wiring it work just for LED :disappointed_relieved: