Prevent LEDs to light when booting Arduino


I have a project involving a LED strip.
LED strip is a 12V with 2835 smd. The Strip is connected to an external 12V AC source.

LED strip on/off is driven by a digital pin from an Arduino Uno Rev2 through a N-Channel MOSFET (IRL3803). Everything is triggered by a push button on a digital input pin.

Now everything works as expected but the only thing is when i turn the power on, the LED strip lights up for 2 or 3 seconds and then switches back off. Then everything runs ok : i can turn the strip on and off with the button.

Seems like there is some current driving the mosfet at boot-up.

Any suggestion to fix this ?

See attached schematic

PS : i have very old and basic knowledge in eletronics.

Thanks a lot

You might have a software problem.


Thanks for your answer.

Well the code seems pretty straight forward, but here it is just in case :

const int buttonPin = 13;     
const int ledMosfetPin = 0 ;      

int buttonState = 0;         // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledMosfetPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT); 

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledMosfetPin, HIGH);
  } else {
    // turn LED off:
    digitalWrite(ledMosfetPin, LOW);

Try putting the mosfet on a different pin, 2 for example.

You are using pin0 to output to the MOSFET.

You need to use pin2 or higher, pin 0 and pin 1 are for programming.

Thanks for the clear schematic and using code tags, (added Karma)

Tom... :slight_smile:
PS. I assume the 12V supply has its gnd connected to the Arduino gnd.


Yeah that did the trick ! Didn't know the Rx/Tx function would cause any issue.
I think i would have encountered some terminal and program uploading issues as well.. ?

Thanks a lot

It's a minor point and common cause for argument, but put the 10k resistor on the Arduino output, not the FET gate.

It's not there to "pull the gate down", but to hold the Arduino output down until it initialises. It is the Arduino's problem not the FET's. :grinning:

oh good to know !

you mean to put the 10k (R7) before the 160 ohm (R5) ?

Yes. Generally not critical - and some people here like to argue the point - but sensible. :grinning:

Yes. Generally not critical - and some people here like to argue the point - but sensible. :grinning:

Yes we do.... :smiley:

well this makes sense :slight_smile:
What could be the issues letting it that way though ?
will have some more tests... and unsolder it if necessary :wink:

thanks a lot