IRF540 Won't turn off

No, that will not work. Put a 10k to 5V so the transistor is held on and a 1k to your pin so the Gnd (pin low) can turn the MOSFET on (transistor off).

Mike.
Edited.

I will try your suggestion. Thank you Mike and also Gophert for helping.
 
.... or just swap R1 and R3 over.
 
Do it this way.

 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…