https://tech.iprock.com/archives/10057
Link: Simple way to control 12V DC Motor using Raspberry Pi’s GPIO port and NPN transistor