You need a low gate threshold mosfet (logic level), Vgt must be lower than the MCU supply voltage.
Vds must be higher that the supply voltage the LEDs are connected to.
Rds ON should be low enough, likewise so for Rth_junction2ambient.
The temperature of the junction will be:
Tj = Tcase + Pmosfet * Rth
Make Pmosfet small and the temperatures will be low.
Another parameter you need to look at is the total gate charge. The larger it is the harder to turn the mosfet on, but for your circuit (low frequency) this is not a problem.
The gate resistor does not matter that much in your case, since you will be driving the mosfet directly with the MCU. The MCU output is "limited to 25mA anyway" - this is not actually true, but if you want to be on the overingeneering side, calculate:
Rg = Vsupply_MCU/25mA
I recommend you show the circuit before trying.
The VN0104 transistor has for instance low enough Vgs(th) to work with a 3.3V MCU.
It has a relatively high Rds ON. The lowest dissipation for the current you mentioned is:
P = 0.4*0.4* 3 Ohm = 0.48W
This is a max power, that is to big to be sustained by such a small device. For 0.5W I would recommend a TO-220 device.
Since you're just switching a magnet, you don't need high speed, or high gate current. However, since your MCU operates on 3.3 volts, you do need some sort of driver to guarantee that your MOSFET gets turned on strongly, and 3.3 volts on an output just won't do that.
For a simple case like this, all you need is a transistor and a few resistors, and
simulate this circuit – Schematic created using CircuitLab
this will do, as long as you don't mind the fact that the signal is inverted. That is, a high output at the MCU will turn the relay off, not on. Note a few things. R2 and R3, when the transistor is off, set the gate drive at 12 volts. Without the combination, using only R2 would apply a maximum of 24 volts to the gate, and this exceeds the maximum specification. Also, D1 is called a flyback diode, and you should always use one when switching anything with a coil. If you don't, when you turn off the relay you'll get a big voltage spike across it, and you may well kill your transistor. Worse, sometimes it will take multiple operations to kill the transistor, so you think you've got a working circuit, but you can't understand why it's unreliable. The diode should be rated for whatever current the relay coil draws, and have a higher voltage rating than the power supply.
Best Answer
Your concept is not completely wrong, but there are some things to keep in mind: