Gate drive for IRF540N using Arduino Uno
I have to run atm so I'll add to this answer later, but yes it is possible to make the arduino switch that fast. An issue to be aware of though is the capacitance of your mosfet. The IRF540N has a gate capacitance of 14nC, so you switching at 1MHz means that you might have to be wary of how much current it will draw. A quick calculation shows that the impedance will be on the order of 10's of ohms, which means the current will be very high (this might be wrong though, I'll double check it later today), which could damage your arduino.