I have 4 small LED lights (raptor lights for a RAV4 grille) for my vehicle and I thought it would be cool if when I start my car, the outer lights would fade in, and then the inner lights would fade in, just for a cool effect when I first turn my car on. I've learned so much so far trying to make this idea happen, but I am at a roadblock and now I have reached out here to see if anyone else would know how I can achieve this.

I have the Raspberry Pi Pico code all set and I have demo code stepping the voltage up to 3.3 V and then back down to 0 V. Using a multimeter, the voltage is stepping how it should.

To power the 12 V source for the lights, I was told that maybe a MOSFET would be best and I hooked up a IRF520 drive module (Link to product) yesterday for the first time. But while the code is executing, the 12 V is not stepping from 0 V to 12 V and then 12 V to 0 V respectively.

I am guessing (and where I need some expertise on) a MOSFET is either on or off based on the signal voltage. Am I correct?

I have some other lights that will be controlled from a timer that I purchased from timers.shop. This timer kind of has this feature, but I want to be able to control the amount of time the fade starts and ends, which the timer is pre-set with a fade value for that.

If anyone could point me in a good direction that would be great. As I am out of ideas currently, as I am a novice to circuit building.

I wanted to post an update on this, and I definitely feel like a newb now. I just received my IRL540N MOSFETs today in the mail and ended up hooking it up and testing the voltage. To my dismay, the voltage was not changing from 0 V to 12 V and from 12 V back down to 0 V using the Raspberry Pi Pico PWM pin. I was really confused why any of the 3 types of MOSFETs were not doing what I needed, so instead of using a voltage meter to check the output voltage, I went ahead and just hooked up the LEDs to the output. To my surprise, my LEDs were fading in and out just how I needed them to! I went ahead and tested some of the other MOSFETs I bought, and sure enough they were doing the same thing.

To sum this all up, it was definitely a learning experience and I should have just checked the lights before but thought checking the voltage would be enough. I am still unsure how the lights are fading in and out if the voltage is not going down to 0 V from 12 V and back up again. So if someone could explain that, that would be great! I'm here to learn!

  • 1
    \$\begingroup\$ "I have demo code stepping the voltage up to 3.3v and then back down to 0" - which 'demo code' are you using? \$\endgroup\$ Sep 13, 2021 at 5:11
  • 1
    \$\begingroup\$ and which 'IRF520 drive module' do you have? \$\endgroup\$ Sep 13, 2021 at 5:15
  • \$\begingroup\$ I would suggest to do the following tests: (1) Use 12V battery with a manual switch to switch on/off your 12V 4 LED stripe. (2) Now add an IRL540 N-channel power MOSFET to control the light intensity of the LED stripe, by using a Picro GP pin 3V3 in PWM mode as an output signal to the Gate input of the power MOSFET. (3) Now the Battery + MOSFET + LED Stripe wiring is roughly like this: (a) Source to 12V+, (b) Drain to Ground, (c) PWM signal to Gate. \$\endgroup\$
    – tlfong01
    Sep 13, 2021 at 5:57
  • 1
    \$\begingroup\$ Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. \$\endgroup\$
    – Community Bot
    Sep 13, 2021 at 12:53
  • 1
    \$\begingroup\$ @tlfong01 When I was researching, I actually saw something about using an IRL540N MOSFET. Thanks for clarifying that, and for all of the other tips too. I will try your suggestions and see the result I get, and will post back here. Thank you! \$\endgroup\$
    – Aaron Olin
    Sep 13, 2021 at 16:00

2 Answers 2


To power the 12 V source for the lights, I was told that maybe a MOSFET would be best and I hooked up a IRF520 drive module (Link to product) yesterday for the first time. But while the code is executing, the 12 V is not stepping from 0 V to 12 V and then 12 V to 0 V respectively.

The product description says:-

  • Voltage: 3.3V, 5V; Output load voltage :0-24V; Output load current: <5A (1A above need to add heat sink)
  • Ports: Digital Level;Platform: Arduino, MCU, ARM, Raspberry Pi.

This is untrue. The IRF520 has a Gate threshold voltage (voltage at which it just starts to turn on) of between 2.0 V and 4.0 V, so at 3.3 V it may not turn on at all.

Many online sellers are promulgating this error (and probably getting a lot of bad customer feedback as a result) but a few do get it right - it only works with 5 V logic and higher (eg. 5 V Arduino). Here's an explanation from one vendor who bothered to test the product they sell:-


Switch loads up to 24V @ 5A 5V compatible (actually semi-compatible. See notes below)

The IRF520 is not fully 5V logic compatible but it will work fine for many applications if it is derated to the specs we show here...

The IRF520 MOSFET device is actually rated for up to 100V @ 9.7A. That rating assumes that it is being driven by a gate voltage of 10V to fully turn the device on with good heat sinking, etc.

Since this module is mainly designed to be used with an Arduino or similar MCU that can only drive 5V, the IRF520 will not be driven to full saturation and therefore will dissipate more heat. For that reason it needs to be derated from the theoretical maximum specs which is how we end up with our 24V @ 5A rating.

In our load testing, driving it with a 5V logic signal and pulling 3A continuous resulted in 56°C on the tab and 3.5A resulted in 71°C

MOSFET Gate threshold voltage is difficult to tightly control, so manufacturers specify it loosely so they can sell more devices. Some purchasers of this FET module may be lucky enough to get one with a low threshold voltage that works 'OK' for them on 3.3 V, while others (like you) get one with a higher threshold that doesn't work at all.

To work reliably with 3.3  logic levels you need a FET which is specified for operation with 3.3  Gate drive or lower (eg. 2.5 V).


Basic concept is that LED brightness depends on the current that flows from it. So, I will suggest you convert that PWM voltage variations to the current variations with the help of a resistor and then feed it to a BJT base instead of a MOSFET. BJT will be able to control the current better with respect to it's base current. example - you can think of as base current varying from 100-200nA which varies collector current 100-500uA.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.