-1

I'm trying to make my case fan turn on using Python code. I have connected the fan to the GPIO 4 pin and the ground pin. The code I'm using is below:

import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(4, GPIO.OUT)
GPIO.output(4, True)

The fan works with both the 5 V and the 3.3 V pins already, but when I connect it to the GPIO 4 pin, it does not spin!

1 Answers1

3

You can't just connect a fan directly to a GPIO pin as the current draw would be too high. Each GPIO pin has a max current of about 16 milli amps.

CoderMike
  • 6,982
  • 1
  • 10
  • 15
  • @irishSenthil I'd say you also risk destroying the GPIO and/or the Pi. If you idly spin the fan you are likely to feed a voltage outside the range 0-3V into the Pi GPIO. – joan May 17 '20 at 21:24