hi there. i have been trying to set up my arduino with a mosfet so that i can switch a liquid pump that runs at 12v, and i have had some limited success. i connected it up as in the attached diagram, and it works (i can swap the base contact from ground to 5v to turn it on and off) but when i try to connect it to a digital pin, the atmega8u2 (using the mega r2) stops working, and i need to disconnect power to it before it will start working again. i just want to know if i've wired it up correctly, and if anyone knows what is causing the 8u2 to stop working like that. cheers
Where's the current-limiting resistor on the gate?
Where's the free-wheeling diode across the motor?
Where's the decoupling capacitor on the motor supply?
You're generating large voltage spikes with this circuit, potentially reseting (or even damaging) the ATmega chip.
You don't say how the Mega is getting its power supply - is this separate from the motor's supply?
the tutorial i watched on mosfets said nothing about caps or diodes, but lastnight i looked up another tutorial it said that i should use a diode accross the load to remove the voltage spike from an inductive load. so i put a diode in, and now it works.