I am fairly new to using MOSFET's in circuits and I am a little stuck. I want to use the IRF540N as a switch, which will receive a voltage to the gate, and 18-30 volts at the drain. I would like for the source to essentially follow the voltage of the drain as long as there is voltage being applied to the gate. I am having trouble getting it to work that way, I tried testing it with a power supply as seen in the picture but I keep getting unexpected behavior. Am I testing it wrong? Should I add resistors or anything else to achieve the desired results from the IRF540N?
datasheet: https://media.digikey.com/pdf/Data Sheets/Fairchild PDFs/IRF540N.pdf
Attempts:
View attachment 220858
datasheet: https://media.digikey.com/pdf/Data Sheets/Fairchild PDFs/IRF540N.pdf
Attempts:
View attachment 220858