Can't figure out how to use pwm with an optocoupler and a MOSFET

Top one looks fine.
When Arduino output is high, LED will light, will turn on NPN to pull MOSFET gate low & turn off the motor. Otherwise MOSFET is on.

I see IRF530 shown as both N-channel and P-channel

Do you have a complete part #?