Erratic MOSFET

Are all your grounds tied together? If the MosFet circuit supply ground and the Arduino ground are not tied together (connected) your results will be unreliable. All grounds must be tied together unless you are using opto-couplers.