pssf84
Posts: 7
Joined: Tue Aug 06, 2019 10:52 pm

Control a 12V LED

Tue Aug 06, 2019 10:55 pm

Hi,

I need to control a 12V LED that is inside a button. I know I can do it with a relay, but wanted to avoid the physical sound of it, can I do it with mosfets? How? Can I use the irlz34n ?

scotty101
Posts: 3958
Joined: Fri Jun 08, 2012 6:03 pm

Re: Control a 12V LED

Wed Aug 07, 2019 8:56 am

pssf84 wrote:
Tue Aug 06, 2019 10:55 pm
Can I use the irlz34n ?
Yes. A MOSFET will do the job and this specific one will also work with the logic levels output by the pi's GPIO pins.

See https://www.raspberrypi.org/forums/view ... p?t=175032
Electronic and Computer Engineer
Pi Interests: Home Automation, IOT, Python and Tkinter

User avatar
neilgl
Posts: 2185
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: Control a 12V LED

Wed Aug 07, 2019 9:23 am

Does the LED inside the switch already have a resistor ? - some you have to add an external resistor to run at 12V (LED is usually around 3V)

pssf84
Posts: 7
Joined: Tue Aug 06, 2019 10:52 pm

Re: Control a 12V LED

Wed Aug 07, 2019 10:13 am

scotty101 wrote:
Wed Aug 07, 2019 8:56 am
pssf84 wrote:
Tue Aug 06, 2019 10:55 pm
Can I use the irlz34n ?
Yes. A MOSFET will do the job and this specific one will also work with the logic levels output by the pi's GPIO pins.

See https://www.raspberrypi.org/forums/view ... p?t=175032
So I think it should be something like GPIO 3.3V to MOSFET G, ground to MOSFET S and 12v to LED + and LED - to MOSFET D ? Is this correct ? Cannot opne button to see if LED has a resistor, it's a push button with a led inside.

Do I need to use diodes?

User avatar
neilgl
Posts: 2185
Joined: Sun Jan 26, 2014 8:36 pm
Location: Near Aston Martin factory

Re: Control a 12V LED

Wed Aug 07, 2019 11:14 am

Do you already have the MOSFET - it is rated at 30Amps but you only need 20mA to drive an LED, so it is an expensive option?

pssf84
Posts: 7
Joined: Tue Aug 06, 2019 10:52 pm

Re: Control a 12V LED

Wed Aug 07, 2019 11:26 am

neilgl wrote:
Wed Aug 07, 2019 11:14 am
Do you already have the MOSFET - it is rated at 30Amps but you only need 20mA to drive an LED, so it is an expensive option?
I already have the MOSFETS irlz34n. Why is an expensive option? How to make it cheaper? But can it be done? Would I need diodes as well? If yes, what kind of diode? any greater than 12V ?

I am controling the 12V LED now by relay, but I want to avoid the physical sound of it...

LesniakM
Posts: 3
Joined: Wed Aug 07, 2019 11:20 am

Re: Control a 12V LED

Wed Aug 07, 2019 11:48 am

Maybe 2n2222 transistor? It handles up to 65V/600mA if I remember correctly(anyway, for sure it will handle ur diode) and still can be activated by Raspi, so would be suitable for this, any maybe many more applications in the future.
Moreover very cheap and extremlly popular around the world.

drgeoff
Posts: 10765
Joined: Wed Jan 25, 2012 6:39 pm

Re: Control a 12V LED

Wed Aug 07, 2019 12:25 pm

Diode not required for switching a LED.

I would advise adding a resistor between MOSFET gate and ground. Value not critical. Anything between about 10K and 100K.

pssf84
Posts: 7
Joined: Tue Aug 06, 2019 10:52 pm

Re: Control a 12V LED

Wed Aug 07, 2019 1:18 pm

So something like this?


https://imgur.com/WCrsISk.png
Image

And if I need to add a 12V fan ? same thing done for 12V LEDs but with diodes?

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 26660
Joined: Sat Jul 30, 2011 7:41 pm

Re: Control a 12V LED

Fri Aug 09, 2019 10:37 am

Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Contrary to popular belief, humorous signatures are allowed.
I've been saying "Mucho" to my Spanish friend a lot more lately. It means a lot to him.

Return to “Beginners”