The IRF540 is an n-channel device. This requires the gate to be brought *higher* than the source to turn on. What’s happening instead is that the FET is following the gate voltage, *minus the threshold voltage*. So if the n-FET gate is at 5V, and threshold is 2V, then it won’t conduct if the drain is higher than (5V-2V), or 3V. Instead, use a p-FET, which switches on when the gate is *lower* than the source. Gate at GND, FET is fully on, gate at 5V, FET is fully off. The AO3401A is a 4A device that would work fine for this.