I'm trying to get a USB fan to work with raspberry Pi 3, by using transistor as the switch. The base of transistor is connected to GPIO 4. And I want to control the fan by switching GPIO 4 on / off. I'm using PN2222A Transistor (NPN)
This setup works with LED light (images below) and I'm able to turn the LED light on / off, but I can't figure out how to make the fan work?
The fan works if I connect it directly to 5v rail & ground. In addition, the GPIO 4 on/off works with Led light.