MAS3:
Hi Wjdan94, and welcome.In this case it's not the LED (which can be easily replaced) that you need to protect.
It is the output of your Arduino pin.
An Arduino pin can be loaded with a maximum current of 40 mA.
You should stay away from that 40 mA or more to protect your Arduino, and the easiest way to do that is by a current limiting resistor.
A standard LED does not have any way of current limiting, so it will fail eventually.
But long before that will happen, the Arduino's pin will be dead.By the way, an Arduino can not output the sum of it's maximum current per pin.
So if you have all pins connected to a LED, and want all of those LEDs to be lit simultaneous then you can't make a design that puts all LEDs on 40 mA.Keep following those projects from the book.
And keep asking questions like this one if you have them.
You'll find out there's some better or easier ways of doing things.
But the book is composed this way so you will learn some basics too.
That way you will be able to do your own projects in the future.
Thank you so much! This is very helpful.
LarryD:
Thank you to @Crossroads :
"The limit is 200 mA Absolute Maximum per VCC & Gnd pin, then the current limit per port and per pin.'328P in a DIP package has 1 VCC pin, thus 200mA limit.
'328P in a surface mount package, thus a 400mA limit.
The Notes in Section 29 show the limits per port, totalling 300mA:ATmega48A/PA/88A/PA/168A/PA/328/P [DATASHEET] 304
8271G–AVR–02/2013
Notes: 1. “Max” means the highest value where the pin is guaranteed to be read as low
2. “Min.” means the lowest value where the pin is guaranteed to be read as high
3. Although each I/O port can source more than the test conditions (20mA at VCC = 5V, 10mA at VCC = 3V) under steady stateconditions (non-transient), the following must be observed:ATmega48A/PA/88A/PA/168A/PA/328/P:
1] The sum of all IOH, for ports C0 - C5, D0- D4, ADC7, RESET should not exceed 150mA.
2] The sum of all IOH, for ports B0 - B5, D5 - D7, ADC6, XTAL1, XTAL2 should not exceed 150mA.
If IIOH exceeds the test condition, VOH may exceed the related specification. Pins are not guaranteed to source currgeater than the listed test condition.
4. Although each I/O port can sink more than the test conditions (20mA at VCC = 5V, 10mA at VCC = 3V)under steady state conditions (non-transient), the following must be observed:ATmega48A/PA/88A/PA/168A/PA/328/P:
1] The sum of all IOL, for ports C0 - C5, ADC7, ADC6 should not exceed 100mA.
2] The sum of all IOL, for ports B0 - B5, D5 - D7, XTAL1, XTAL2 should not exceed 100mA.
3] The sum of all IOL, for ports D0 - D4, RESET should not exceed 100mA."
If IOL exceeds the test condition, VOL may exceed the related specification. Pins are not guaranteed to sink current greater
than the listed test condition.hl
Important information. Thank you!
=
Please help with ERROR: stk500_recv() - Couldn't find a solution - IDE 1.x - Arduino Forum