control Constant Current-Electromagnet

billybouki:
the code is real simple. just controlling the analogWrite value from outside. (works with led)

the problem seems to be on the circuit. (see above) my transistor http://www.irf.com/product-info/datasheets/data/irlz24npbf.pdf

im measuring small variances in amperes but insignificant to make a change.
sorry for newbiness . really apreciate your replys

Well the circuit design is correct, the MOSFET is a proper logic level device. So that leaves your code to look at, can you post it?