Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4777

Python • Re: 5V fan wont turn on using code

$
0
0
Which transistor are you using ? What is value of resistor ?
Any errors from the python code when you run it ?

My debug procedure would be
- check the GPIO output
disconnect the wire from GPIO18
to GPIO18, connect a LED with series resistor 330Ohm to 1kOhm to GND (or measure voltage with multimeter from GPIO to GND)
LED should be bright when code reports 'on' (or voltage should be around 3.3V)
LED should be dark when code reports 'off' (or voltage should be around 0V)
If not working: check your code
connect the wire back to GPIO18

- check the fan
disconnect the fan from the breadboard circuit and connect its two wires direct to VCC 5V and GND.
expected: the fan starts to turn
if not working: fan is bad or 5V is too low voltage for the fan.
connect the fan back to your circuit

- check the transistor with 3.3V control signal
disconnect the GPIO 18 wire from the adapter, keep the other end connected to resistor
connect the open end to VCC 3.3V
expected: the fan should start
connect the wire back to the GPIO pin
if working: done, check your code
if not working:
if transistor is a NPN transistor, check connections and resistor values.
if transistor is a mosfet transistor, check connections.

- check the transistor with 5V control
Do this only if you have a mosfet transistor.
disconnect the GPIO 18 wire from the adapter, keep the other end connected to resistor
connect the open end to VCC 5V
expected: the fan should start
if working: Transistor switches with 5V, but not with 3.3V. Possibly you have a mosfet with too high threshold voltage.
check transistor connections.
Buy a logic level mosfet.

Statistics: Posted by ghp — Wed May 01, 2024 3:59 am



Viewing all articles
Browse latest Browse all 4777

Trending Articles