I am trying to control a 6v DC motor using Arduino, by feeding a PWM signal to the base of an NPN transistor hooked up to the motor circuit as shown in the schematic below.
simulate this circuit – Schematic created using CircuitLab
Individually, both circuits work fine; if I remove the transistor the motor spins and if I try to control the brightness of an LED using the output of D5 that also works, but when I introduce the transistor, it fails. I've tried both with the motor + transistor and an LED + transistor, but same problem: nothing happens.
My assumption is that it has to do with my choice of transistor - that a 2N4401 is just not the right kind for this - but if that's the case, I don't really understand why this one doesn't work, or what to look for in one that would work.
(I would also be willing to accept that I have completely misunderstood how transistors work and that there is something else wrong.)