Hello, I am trying to use one of the GPIO pins of RAMPS to

Hello,

I am trying to use one of the GPIO pins of RAMPS to drive an external MOSFET. The gcode command for above ia [M42] [P] S

By default it will set LED_PIN (pin no 13) if I haven’t explicitly given any pin number. But I am not seeing any effect of this.
Tried sending both M42 P13 S0 & M42 P13 S1

You’re looking at the pin state directly, right? Not through your circuit?

Try with s values of 0 and 255