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

General discussion • Using P-Channel Mosfet with RPI Pico W

$
0
0
Hi there I got quite a project on my end I am using a mosfet specifically IRF4905 now the I want to turn on a 12 volts LED using this

I have the following materials

12v power supply
pi pico w
12v LED
IRF4905
10k Resistor

Wiring is as follows
Image

now base on what I read and research (I don't know if I understand correctly) to turn ON the mosfet you have to supply the gate a 0v and to turn it off you have to supply 2v or higher (again I'm not sure correct me if I am wrong)

now my code looks like this

Code:

from machine import Pinimport time# Initialize GPIO 0 as an output pingpio_pin = Pin(0, Pin.OUT)# Function to set the GPIO pin to high (3.3V)def set_pin_high():    gpio_pin.high()    print("GPIO pin is set to 3.3V")# Function to set the GPIO pin to low (0V)def set_pin_low():    gpio_pin.low()    print("GPIO pin is set to 0V")while True:    set_pin_high()    time.sleep(1)    set_pin_low()    time.sleep(1)
i don't know what is wrong but when I test the negative wire and positive wire of the out to LED still having 12v on the reading

Statistics: Posted by mugichan — Sun Jul 21, 2024 2:26 pm



Viewing all articles
Browse latest Browse all 5349

Trending Articles