Controlling the speed of a dc motor?

2N3904 is far too puny to control a motor, it's designed to switch currents of 10mA or so. For small motors, you can use a medium-current transistor such as BC337 or 2N2222A, with a base resistor of between 100 and 220 ohms. For larger motors, use a mosfet instead of a bipolar transistor.