When we have an Arduino project in which there is an LED that is powered through a pin, one would think that it is enough to connect it to the pin and GND. But is it correct?
To take away the doubt we can try to plug it in, and we would see that the LED lights without any problems.
This type of connection is not recommended except for a short time, because the LED has a very low resistance, so an high current will circulate, and may damage the LED and the pin, which can deliver up to 40mA.
We must then insert a resistor in series with the LED, and size it using the first principle of Kirchhoff.
where V is not just the voltage of the Arduino’s pin (5V), but it subtracted the voltage ai capi del led, which depends on the color of the LED.
- red: 1,8 V
- yellow: 1,9 V
- green: 2,0 V
- orange: 2,0 V
- blue: 3,0 V
- white: 3,0 V
I is the maximum current that can withstand the LED without burning, and ranges from 15-25 mA.
for example if we use a red LED, the resitance will be: