How do transistors work?

I'm trying to understand transistors. Specifically the 2N2222A that came with my Arduino kit. From what I can gather there is an input (collector) and an output (emitter) that are not closed normally. When voltage is applied to the base it closes the circuit between the emitter and collector?

Can I use a transistor to switch current that's not the same as the base. Specifically can I feed the base 5v (digitalWrite(1, HIGH)), and have the emitter and collector switching 12v? Or do the voltages have to match?

What you want to do is possibel, see:- http://www.thebox.myzen.co.uk/Workshop/Motors_1.html