10K resistors - Getting Started With Arduino Book?

I have some experience with hobby electronics, but I am new to the Arduino. So I am working through the book "Getting Started With Arduino" after which I have 2 other books I can use to continue on into more advanced projects. But I have a question. When I bought the Arduino UNO board and this book on Amazon, I also got the Starter Kit for components, wire, mini-breadboard, etc. In that kit they supply several typical 5mm LEDs and some 330 Ohm resistors. However, the book keeps saying to use 10K resistors on all the LEDs and other circuit paths in the projects requiring resistance. I know that according to Ohm's Law for DC, I=E/R, so the current that will pass through a 10K resistor fed with 5V (the source for all the projects in this book is the 5V pin on the UNO) is only 0.0005A - barely enough to coax light from an LED. All the 5mm LEDs I have here are capable of at LEAST 20 mA current, and some go higher.

If I sub in a 330 ohm resistor, I=E/R then results in 5/330 = 0.01515A. 15mA is a very nice current load to keep a typical LED happy. So I have to think the parts kit vendor substituted the 330 ohm resistors for the 10K values which are referenced in the book. I know using the 330 ohm resistors for the LEDs will be safe, for sure. What I would like to know is if I can use the 330 ohm values in place of all the resistors used for other purposes in the book's projects, such as project 06A where the LDR is used in series with a resistor as an analog input to vary the brightness of the LED on the UNO board, without harm to the Arduino board itself? It is mentioned later in the book that the Arduino can handle "loads up to 20mA" on its (output?) pins, but I wanted to make sure the same thing applies to inputs before I ignore the repeated references to 10K resistors and just use the 330 ohm values supplied in the kit.

What page does it say to use 10K resistors on all the LEDs?

On page 43, for example, it mentions a 10K resistor but as a pull-down to ground, not for the LED.

330 ohms sounds right for the LEDs, but 10K is more right for pull-up or pull-down resistors (and 330 ohms is too low in that situation).

Hi,

Thanks for the quick reply and information. :)

The thing is, although I have 'some' experience in hobby electronics, Arduino is new to me, so I like to follow instructions precisely if possible. That said, page 43 does mention using a 10K resistor, but there is nothing on the page mentioning "pull-up resistor". You know that is what the resistor is for because of your experience. But this book is written for people who have little or no experience at all with electronics. Had I not previously learned what a pull-up resistor was, I would now have to ask you to please explain that to me.

My previous encounters with pull up resistors were brief, and not in the manner used on page 43, so all I was seeing is that they added a resistor to limit the current in that circuit branch, and even that concept is probably unknown (as to why one might want to do that) to a budding Arduino hobbyist.

Until I got to page 83, all the resistor references for projects on pages 58 and 65 did not mention any values at all. I was left to "assume" a 10K resistor should be used, since that is the only value previously mentioned in the brief list of parts needed to follow the book. But on page 83 is is finally mentioned "You need to use 10K resistors for all of the resistors shown in the diagram, although you could get away with lower values for the resistors connected to the LEDs".

Only because my previous learning taught me about LEDs and their operating requirements would I even be equipped to hazard a guess as to what value of resistor would be best as a current limiter for LEDs, (or, if viewed from a beginner viewpoint, why they are needed at all), why I might not want to use the 10K value, and what other value ranges I need to avoid. Clearly this book has some shortcomings. :)

But what I needed to know here is what is 'safe' for the resistance ranges I would use for the other, non LED-powering branches of circuits in my Arduino projects. It just didn't seem prudent to me to have only 0.0005A flowing in those parts. That didn't seem like 'enough current', and I would have guessed at a few mA being a better choice. Especially while using a breadboard, which some engineers I have met outright refused to use, claiming press in breadboard connections were too unreliable. Having a little more current seems like a good idea then, as long as it is a reasonable amount.

The parts kit I bought on Amazon in conjunction with the UNO board has only 330 ohm resistors. I found a post elsewhere on this forum last night which led to a nice table of comparisons for what to buy when starting out. Most of the other kits have multiple values of resistors ranging up to 10K. But now I have to think that the vendor selling my kit must have presumed 330 ohms was an adequate "universal value". So their opinion would be that 5V/330 ohms = about 15mA is acceptable current through all parts of the Arduino board, including the pull-up resistor on page 43?

You suggested 330 ohms is not high enough resistance for that task. So what current level would you prefer to see in the peripheral circuitry of the UNO board?

I have a vast assortment of resistors, so I can use pretty much any standard value recommended. The main reason I selected that kit was to make sure I had the parts to go through the book, and because the kit was conveniently sold along side the UNO on Amazon.

But what I needed to know here is what is 'safe' for the resistance ranges

Sorry there is no such thing, you need to look at each situation and do the calculations.

Using 10K on an LED is simply wrong.

It just didn't seem prudent to me to have only 0.0005A flowing in those parts.

That is half a milliamp in some situations this is a massive amount of current, it is a perfectly respectable amount of current. As a pull up or down resistor in series with a sight sensor 10K is fine but you might want to go to 100K it all depends on the sensor.

I must admit the book is pretty vague on that page. And on page 31 it shows an LED being shoved into two pins with no resistor at all! And the book is vague in other places, like not mentioning resistor values

I must admit that I share your pain on this one. Sometimes I see a 4.7K resistor specified and wonder "well, why not a 5.6K, what difference would it make?".

For experimenting, probably "ball park" will be OK. So for an LED, something in the range 100 to 500 ohms in series (again, depending on the LED). Too high, and the LED will be a bit dull. Too low, and it might burn out, or overload the output pin of the Arduino.

There is a nice web page for calculating LED resistor values:

http://led.linear1.org/1led.wiz

As for pull-up and pull-down resistors, generally they are for situations where you want a "default" value for a pin, rather than having it "float" and just randomly taking stray voltages as its value. So in those cases something like 10K is enough to pull the pin down to ground, or up to 5V, without putting too much load on the circuit.

Think of it like a spring to close your door. The default position is you want the door closed. Too tiny a spring, and the door won't close. Too massive a spring and you won't be able to open it when you want to. A "just right" spring will gently close the door, but let you "fight it" to get it open. And of course there is no exact "just right" spring. Slightly bigger and the door will close with a bang, slightly smaller and it might take a long time to close.

But now I have to think that the vendor selling my kit must have presumed 330 ohms was an adequate "universal value".

I can't really agree with this. There is no "universal value" resistor. You really need to look at the job at hand. You were right to do the calculations for the LED, so you came up with the right results. Say you used a 330 ohm as a pull-up. According to my calculations that is 15mA which is acceptable for the pin, but really a bit high. The specs seem to say that the I/O pins can source 20mA, but the sum of all pins must not exceed 150mA.

My advice is to look at circuits and see what other people are doing in similar situations to what you are doing. So generally smallish resistor values in series with LEDs, and largish ones for pull-ups. And of course the voltage of the circuit will influence the results. So if you have a 10V circuit the resistors will be different compared to a 5V circuit.

Got curious so I pulled up the book in Safari Online and it looks like on page 43 they are using the 10k as a pulldown resister for the button, not a series resistor for the LED. They are relying on the built in resistor on pin 13. (Which I thought didn’t work, but that’s another story.)

Grumpy_Mike:

But what I needed to know here is what is 'safe' for the resistance ranges

Sorry there is no such thing, you need to look at each situation and do the calculations.

Using 10K on an LED is simply wrong.

It just didn't seem prudent to me to have only 0.0005A flowing in those parts.

That is half a milliamp in some situations this is a massive amount of current, it is a perfectly respectable amount of current. As a pull up or down resistor in series with a sight sensor 10K is fine but you might want to go to 100K it all depends on the sensor.

I would agree with you on doing the calculations for each project condition. What I was looking for here was more a "do not exceed" value in terms of pin current. However, take a person completely new to the UNO (me) and how can one calculate when one has NO idea of the values of the variables??

The getting started book doesn't cover things like how much voltage and current are available or tolerable on each I/O pin. I had to "assume" that 5V is being supplied to that LDR ( I did not test it). And using a 10K there, the LED was extremely dim when it came to project 06B. At first I thought it was not working, until I repositioned the LED so I was looking directly down onto its top.

While I was waiting for replies to my previous post I did some digging online and eventually turned up a PDF spec sheet for the ATMega328 chip in the UNO. Over 500 pages. But fortunately for me they listed "Electrical Characteristics" in the index. Under "absolute maximums" it says any individual I/O pin should not exceed 40mA. That was more than I expected to see, but it certainly allows for the use of a 330 ohm resistor with that LDR on page 43, presuming a voltage of 5V, and allowing for the fact the LDR adds even more resistance. I did not see any reference to the combined total current on all pins mentioned in the next reply below, but then looking at a spec sheet can sometimes get confusing for me. ;)

I can't really agree with this. There is no "universal value" resistor. You really need to look at the job at hand. You were right to do the calculations for the LED, so you came up with the right results. Say you used a 330 ohm as a pull-up. According to my calculations that is 15mA which is acceptable for the pin, but really a bit high. The specs seem to say that the I/O pins can source 20mA, but the sum of all pins must not exceed 150mA.

My advice is to look at circuits and see what other people are doing in similar situations to what you are doing. So generally smallish resistor values in series with LEDs, and largish ones for pull-ups. And of course the voltage of the circuit will influence the results. So if you have a 10V circuit the resistors will be different compared to a 5V circuit. [/quote]

I am familiar with how the current load would change as the circuit voltages change with respect to resistance, so I agree that is a needed consideration.

To add to what I posted above, it would be interesting to see, in that data sheet, the "absolute minimums" for the electrical characteristics. I noticed the current rating on the chip's input power is really tiny, like around 1mA. And in addition to that, there is a whole section on conserving power to an even lower level! So I suppose the I/O pins may easily operate reliably with less than 1mA of current. These are all new pieces of information to me, so I am learning here. I appreciate you folks helping me out!

It appears that, for the projects in that book, using either 330 or 10K resistors "will work". But we have just nicely discussed why each value may not be the best choice. I suppose the kit I bought was limited to one value to make things look simpler, perhaps?

For now I'll continue to calculate the LED load resistors (because I know how) and use the 10K values for the I/O pins, unless I run into something that doesn't work because it appears not to be getting any current. When in doubt I can always put an ammeter in the line. ;)

Thanks again!

Page 314:

1. Although each I/O port can source more than the test conditions (20 mA at VCC = 5V, 10 mA at VCC = 3V) under steady state conditions (non-transient), the following must be observed: ATmega48PA/88PA/168PA/328P:

1] The sum of all IOH, for ports C0 - C5, D0- D4, ADC7, RESET should not exceed 150 mA. 2] The sum of all IOH, for ports B0 - B5, D5 - D7, ADC6, XTAL1, XTAL2 should not exceed 150 mA. If IIOH exceeds the test condition, VOH may exceed the related specification. Pins are not guaranteed to source current greater than the listed test condition.

Notice they mention 20mA as a "test condition" so I would aim for that rather than the absolute maximum.

Zoandar: So I suppose the I/O pins may easily operate reliably with less than 1mA of current.

Er, yes. I suppose it depends what you mean by "operate reliably". But given that 10K pull-up resistors are used then that would seem to imply that it can, ah, detect 500 microamps (5/10000). In fact the internal pull-up resistors are closer to 40K, and they can be used for switching, so you can probably say the input pins can detect 125 uA.

And wading through the data sheets a bit more (what is "bandgap reference current consumption", eh?) it would appear that it can probably detect input currents in the order of 10 uA (page 321).

[quote author=Nick Gammon link=topic=53901.msg386151#msg386151 date=1299019536] Page 314:

1. Although each I/O port can source more than the test conditions (20 mA at VCC = 5V, 10 mA at VCC = 3V) under steady state conditions (non-transient), the following must be observed: ATmega48PA/88PA/168PA/328P:

1] The sum of all IOH, for ports C0 - C5, D0- D4, ADC7, RESET should not exceed 150 mA. 2] The sum of all IOH, for ports B0 - B5, D5 - D7, ADC6, XTAL1, XTAL2 should not exceed 150 mA. If IIOH exceeds the test condition, VOH may exceed the related specification. Pins are not guaranteed to source current greater than the listed test condition.

Notice they mention 20mA as a "test condition" so I would aim for that rather than the absolute maximum. [/quote]

Although I would never aim to use the absolute maximum parameter on such a device, thank you for digging up this spec. That tells me that using a 10K resistor is certainly not 'essential' to normal operation on the I/O pins. My previous guess that setting the pin current to 'a few mA' certainly seems safe and logical for most applications. :)

Zoandar: So I suppose the I/O pins may easily operate reliably with less than 1mA of current.

Er, yes. I suppose it depends what you mean by "operate reliably". But given that 10K pull-up resistors are used then that would seem to imply that it can, ah, detect 500 microamps (5/10000). In fact the internal pull-up resistors are closer to 40K, and they can be used for switching, so you can probably say the input pins can detect 125 uA.

And wading through the data sheets a bit more (what is "bandgap reference current consumption", eh?) it would appear that it can probably detect input currents in the order of 10 uA (page 321). [/quote]

It is unfortunate that there is no simple and reliable way of converting AC voltage less than 1V into DC. With the UNO's ability to work with such tiny currents (and presumably voltages) it would open up the capabilities even more. I had to abandon considering the Arduino as an "easier" contender to read the mVAC signal off a current transformer I like to use for monitoring devices running on house current because it was easier to just clone the circuit I had previously built (which uses comparators) than to try to convert the current sensing transformer's output to something the UNO could read.

Maybe someday they'll invent a diode that can work in mV. :grin:

Thanks guys!