A gate resistor is used in these Arduino applications to protect the output transistors inside the Arduino/micro-controller.
This is one of the cancer-like misinterpretations spread commonly on this forum. There is loooong topic about this which IMHO proves a pin driver damage is not a valid reason for a gate resistor. Maybe if the MOSFET were really huge and it were switching very light load. Otherwise you damage the MOSFET by slow switching before any damage to the pin may be done.
God knows we hate inaccurate information on the forum. It's like cancer , you have to remove itbefore it spreads...
Will adding a (example) 220R as a series resistor cause a problem, No!
OK...so here's what I know.1) Within reason one cannot supply too much current to the gate. Power MosFets are typically driver with 2 to 10 amps from a specialized driver.
2) The noise I was referring to is that created by a fast switching drain, resulting from a good amount of current supplied to the Gate.
3) As the Gate voltage rises from Zero, the gate voltage will rise as well until the drain starts to reduce in voltage. For the time the drain is switching from off to on, the gate voltage changes very little. The more current you supply to the gate, the faster the drain will switch. Conversly lowering the gate drive capability will slow down the switching time resulting in less generated noise (EMI)
4) The -3db point of the generated noise frequencies caused by a fast switching time at the drain is approximately 0.35/rise time. So one can see fast switching times causes radiated noise that can be picked up by nearly anything close by. With a reduction in switching time, the radiated noise can be reduced significantly.For a simple test I would use a cheap AM radio (hard to find these days). I would tune to the lower portion of the AM band and hold it near the switching device. If the noise could not be heard above hiss on the AM band the design is close and worth testing in the screen room (an RF sealed room used for testing EMC emissions)NEW SUBJECT:Component datasheets are written under "ideal" or maybe "unrealistic" conditions. A seasoned designer knows how to interpret these characteristics and can apply them to the design. The novice will eventually learn but for the moment one should assume the MosFet should have a max current of at least 10X the expected current. This 10X number is not cast in concrete but it gives the novice some place to start.
On your part (BS170) The OnSemi data sheet has a note by the max current. "NOTE: The Power Dissipation of the package may result in a lower continuous drain current." This means the heat generated in the MosFet trying to drive 500 ma will cause the MosFet to be damaged as the heat causes the device to exceed its maximum temperature.This is just the tip of the iceberg regarding the application of a MosFet. You should try to find a good application primer.
Size a MOSFET using the on-resistance.