DC motor
An interfacing method for turning on and off a DC motor via a microcontroller is shown below. However, the above circuit will only work for a 5 V motor. If the supply voltage is changed (for example, if the supply is changed to 12 V to run a 12 V motor) then the motor will be on all the time because 5 V applied to the base of the p-n-p transistor is not enough to turn it off.
To interface to larger motors the following circuit may be used.
Bi-directional DC Motor off 1 (5 V) reverse forward