I’m building a airsoft sentry gun. The plans show a resistor R2 in one spot. But people on another forum tell me that it is not a good spot and a new resistor of around 270 ohms or 220 should be put in circuit with the gate of the mosfet instead. They say its because Arduino pins can actively source and sink current. but lots of people have built sentry guns and have had no problems with the wiring. I don’t really understand ether placement I just know its to protect the arduino. Please help tell me ware the resistor should go. Thank you!
The circuit you have will probably work fine. If it was an NPN transistor you would need the resistor but with a mosfet it's unnecessary. It might help to prevent "ringing" but I doubt you'll need it.
A resistor in the gate circuit is a good idea as it limits the current out of the arduino pin to a safe value without having any effect on the drive.
R2 is there to discharge the gate capacitor to turn the MOSFET off quicker.
R2 also keeps the MOSFET off while the Arduino is in the Reset state and the IO pins are floating.
To clarify this - it's not a matter of "one or the other" resistor.
weedpharma: R2 is there to discharge the gate capacitor to turn the MOSFET off quicker.
No it isn't - that is nonsense.
The placement of R2 you indicate and its value, is to ensure the FET is turned off when the Arduino is not controlling it, such as during a reset. You could otherwise get the motor randomly operating during a reset.
A series resistor of 220 ohms between R2 and the gate of the FET is good practice to limit the charging current of the gate as it is switched on and off by the Arduino. This only occurs for a few microseconds each time and the Arduino chip will probably tolerate it quite OK, but it is a point of good conservative design, just in case.