first of all, thank you for this great forum which help me to intro to Arduino.
I want to control a small dc motor with a pin from Arduino. I saw a schematic here http://www.hispavila.com/3ds/atmega/motorescc_files/motorcc_tr.gif and I am wondering how can I know the kind of the transistor for this power (5v)? Also, why do I have to put a resistor in front of the Arduino's pin? It is protection? I know they are electronic questions.
If you think about it, the voltage has very little to do with the choice of transistor.
Imagine you'd said "12V motor" - it could be a model railway loco...or a diesel engine starter motor.
Both could be termed "small".
The diagram suggests an NPN, but you need to know the stall current of the motor.
I think the TIP120 may be overkill, but is a good solid common transistor to use for stuff like this.
It is a Darlington (actully it is two transistors in one package), so has high gain, and is good for up to about 5 amps (IIRC).
The 2n2222 is good for up to about 1 amp, but the gain is only about 1/3rd that of the TIP120.