Arduino Mosfet control
You have the MOSFET backwards with the drain and source interchanged.
Likely when &quot;off&quot; you are still getting a path through the body diode in series with the LED, and when &quot;on&quot; you bypass that causing the LED to be brighter as the structure is symmetric enough that it can work &quot;a bit&quot; in the opposite direction.