I am using a MOSFET to switch power on and off to a 115 volt AC fan. I connected the ground of the chip to the ground on the Mega and the positive to a digital out. When I connected the USB cable to the computer, the board blew up. I have photos of my setup below:
Using a 36V DC MOSFET to operate a 115V AC fan doesn't work.
Voltage isolation wasn't strong enough. High voltage took path via USB cord to blow up chip.
You maybe should have used a solid state relay instead
Look at it this way you learned about AC/DC and Volts. I know the next time you will check them and will NEVER EVER connect a mains line to an Arduino.
And worse: the gnd track goes straight from 115AC to the board... (you might be lucky though as one of the 115VAC wires is Neutral...).
But looking at the damage, I suspect that OP was not that lucky today. Good thing is that he himself did not get damaged (maybe his ego though).
By the way, it was not the MOS FET that blew up your board...
You can develop you code with the Wokwi simulator: https://wokwi.com/
Nothing gets destroyed, guaranteed.
Wokwi does not have a fan, but you can use a led instead.
Why do you need an expensive board like the Arduino Mega 2560 ?
I suggest to use a closed module to control the mains voltage, such as a Fotek SSR. But you better show us a photo of your wiring first, so we can confirm that a wire will not get loose.
No, he used up all his luck for today, he should go inside and not do anything for the rest of the day
“A person that started in to carry a cat home by the tail was getting knowledge that was always going to be useful to him, and warn't ever going to grow dim or doubtful.” - Mark Twain