I'm a newbie (and an old one)
After months spent reading posts, studying tutorials, I still don't understand the inner conections of the Arduino R4 wifi.
If digital and analog I/O pins must be protected with aprox. 660Ohms resistors, in order to minimize current to aprox. 5mA...
Wouldn't that reduce the voltage that we are supposed to read in the I/O pins?
Pins used as outputs do have a current source or sink limitation of a few mA, and in some cases, like driving an LED or an NPN transistor base, it is generally required that you use a series resistor to limit the current flow.
Hello Jremington.
That's the scenario where I have read about GPIO protecting resistors.
Assuming that I need to activate the gate of a transistor (to dim a 12V led via an output pin using PWM)...Wouldn't a resistor reduce the voltage that reach the transistor's base?
I see a lot of tutorials using that kind of GPIO protection...And I get confused.
It's reducing the current to base. More correctly, limiting the current.
Also if you want to limit the current to 5mA, you need 1k resistor, not 660ohm.
These two types of transistors work in quite different ways.
BJTs are switched on or off by the amount of current flowing into the base. They don't care about the voltage, only the current. So, yes, a resistor in series with the base will reduce the voltage, but it doesn't matter.
FETs are switched on or off by the amount of voltage connected to the gate. But their gates have very high impedance (kind of like resistance) so only a very tiny current will flow, whether you connect a resistor in series or not. If you do, because the current is tiny, only a tiny amount of voltage will be dropped by the resistor.
However, because the gate of a FET is like a small capacitor, if you switch it on and off at a high frequency, the impedance drops and more current flows. At very high frequencies, this current could damage the Arduino pin, and so a resistor is recommended to protect it.
Ohm's Law defines the relationship between voltage, resistance and current.
Resistance is "the resistance to current flow".
Generally, the voltage is fixed (or controlled) and the current depends on the resistance (or impedance) of the load. For example, when nothing is plugged-into a power outlet in your house no current flows. When you plug something in and turn it on, current flows. A hair drier or toaster "pulls" more current than a regular light bulb and if you plug-in (and turn-on) a toaster and hair drier at the same time, if they are on the same circuit you'll draw excess current and blow a circuit breaker!
The base-emitter junction on a transistor is essentially a diode, which is non-linear. That means that the resistance changes when the voltage changes. As the voltage goes up the resistance goes down. As you go above about 0.6V the resistance goes VERY low and without a series current-limiting resistor you'll draw excess current from the Arduino.
BTW - LEDs are also non-linear diodes and they also generally need a current-limiting resistor or some kind of current limit/control. You might not be powering your "12V LED" properly...
An NPN transistor base has a voltage drop of about 0.7 V under normal operating conditions. The resistor is required to keep the base current below the maximum recommended value that the port pin can handle. Use Ohm's law to calculate the resistor value.
These are extremely basic electrical circuit concepts that you will need to study and master, if you want to be successful in this technical hobby.
When we set a pin to input, the new series 240R has no significant effect on a digitalRead as the input resistance is 100meg.
When we set the pin to output, the 240R can be connected to a LED, base of a BJT or the gate of a MOSFET; 240R has a negligible effect on a output pin.
I knew all that already (although yes, I have to study more)
If I understood it well, the helpful answer has been that the current through the MOSFET's base is so tiny, that the voltage drop is negligible, allowing transistor base activation normally, with or without the resistor.
Whether you are using a MOSFET or BJT you still need a resistor to limit the current, otherwise in the case of the MOSFET you may damage the driving device and for the BJT you could damage both.