Dimming two Strips from 12v Battery

Hello All,
Hope some one can shed some light on my project.
I have installed a LED light system in my campervan run from a 12v secondary battery.
My system worked fine for the first 10 seconds then the mosfet controlling the front lights blew.
Efficiency is high on my list of requirements ( to enable off grid camping for the longest period).
Any advice gratefully received.

this is my code -

// IN and OUT from Arduino

const char POTI_FR = 0;
const char POTI_RE = 1;
const char SWITCH_FR = 2;
const char SWITCH_RE = 3;
const char OUT_FR = 10;
const char OUT_RE = 11;

// record varables

int input;                                      // variable de stockage de la valeur lue sur le poti
int output;                                     // variable de travail pour transformer le pwm

int pwmmax_fr = 40;                               // pwm max pour le secteur 1 afin de ne pas bruler les led
int pwmmax_re = 40;                               // pwm max pour la sortie 2


void setup()  
{
  //Serial.begin(115200);
  Serial.println("Salut");
}

void loop()  
{  
  input = analogRead(POTI_FR);                     // stockage de la valeur lue sur le premier poti
  output = map(input, 1020, 3, 0, pwmmax_fr);
  output = constrain (output, 0, pwmmax_fr);
  analogWrite (OUT_FR, output);
  Serial.print("level out front = ");
  Serial.println(output);
  
  input = analogRead(POTI_RE);
  output = map(input, 1020, 3, 0, pwmmax_re);
  output = constrain (output, 0, pwmmax_re);
  analogWrite (OUT_RE, output);
  Serial.print("level out rear = ");
  Serial.println(output);
  
  Serial.println();
  
  //delay(500);

BusLightSchamitic.pdf (28.7 KB)

There is no MOSFET driver, which means all charge is directly to mcu-chip. Add a resistor (100..200 Ohm) to safeguard the I/O-pins.
The transistor in not very fast-switching - it will get warm. Cool it.
I'd also add "an Ohm or ten" in series with the LEDs to make sure current is in safe range. (100mA) U'll have to measure this when battery in 14V+

Thanks for that knut_ny, can you tell me what other options I have instead of MOSFETS, or point me towards useful tutorials ? I had a look around but my with my basic understanding I just get more confused.

Thanks again for your time.

Phil

MOSFETs are the best option - you just need a current limit resistor in the LEDs string.

Are the LEDs really in one long series string like that? They have a Vf of 3.5V or so, 12V is not enough to make them all light up.
I would use this transistor

with multiple parallel strings of 3 LEDs and a (12V - 3 x 3.5)/.02 = 75 ohm resistor each.

Yep your are spot on CrossRoads the are not in series ( late night rush do my circuit diagram) they are in parallel. I did wonder if having two strings with such a large difference in LED's would have a bad effect.

Replace the broken transistor a logic level MOSFET, same type or other .. eg IRL520,IRL540,30N06L
Normal current is close to 100mA. Adding a resistor, eg. 10 Ohm, source to ground. - will act as current limiter.
This way the transistor can never deliver more than 300mA. This resistor will, worst case, emit <2W (hot)
Use a 5W resistor. Note that also the transistors will get hot if it is in its active zone.
Under normal conditions, 100mA, the resistor emits less than 200mW (warm)
Transistors (and resistors) needs cooling.
........
Use your multimeter to check that 'normal' current, 100% light isn't more than ca. 100mA
Voltage at source ( with 10 Ohm added) is no more than 1V. It it is..: add another diode in the chain.
.........
and.. after seeing the serial/parallel..: choose 3..4 in series in each chain