PWM control of an electromagnet with Arduino.

Arduino's pin is protected with 4N35 optocoupler.

MOSFET is IRF520 (RDS(on) = 0.27Ohms ==> gets hot).

Inductance of electromagnet is unknown (home made)

R0 will be removed in a future design since it gets hot as well (5ohms and 2amps).