arduino projects book: 10k vs 220 -ohm resistor in chapter 2 and chapter 1

Hi all,

I am new to Arduino and electronics. Would someone able to help me to understand why in Chapter 1, we are using a 220 ohm resistor for the push button and in chapter 2, we are using a 10K one?

How would we know what resistor to select when building our own project?

Many thanks,

It would have helped if you had linked the chapters / book :wink:

In chapter one you use the 220 Ohm resistor as a current limiting resistor, so you won’t blow your LED. In chapter two you still use current limiting resistors but this time you also added a pull down resistor for the switch.

That pull-down resistor connects the pin to ground when the
switch is open, so it reads LOW when there is no voltage coming
in through the switch.

You will find information on that in the forums / google. But basically you want to avoid an input to be floating (not knowing whether it will read HIGH or LOW) because you tie it to GND.

Maybe it would have been more intuitive to group the resistor with the LED in the schematic, rather than placing the switch in between.

Already answered by chuckyx but this has a little more info so I’ll post it anyway:

I don’t own the book and you haven’t provided any details on the surface but I’ll take a wild guess.

220 Ohm is a common value to use as a current limiting resistor for an LED. If you connect an LED directly to your Arduino board it will draw more current than the microctontroller can safely provide and damage it. Even if that wasn’t a problem, it can provide too much current to the LED itself and burn it out. A resistor limits the current to a safe level. You could pick from a range of safe resistance values. 220 Ohm is at the low end of the range. It will cause the LED to be very bright while still not drawing too much current. If you used a 1000 Ohm resistor instead the LED would be more dim and would draw less current. If you used a 10000 Ohm resistor the LED would not be lit up at all. A simple equation tells you the resistance value (R) required to achieve a given current draw of the LED (ILED) but you do need to know the supply voltage (Vs) and the forward voltage of the LED (VLED). The supply voltage is obvious enough. You can find the LED’s forward voltage listed in its datasheet. Lacking that information you can start with the common forward voltage of the specific LED color you’re using, which will be in the ballpark. Then the equation is R=(Vs-VLED)/ILED.

10K Ohm is a common pull-down or pull-up resistor value. This is likely to be a pull-down in this case since the Arduino’s microcontroller has internal pull-up resisotrs you can turn on in your code. By connecting a resistor between the switch pin and ground it puts the pin in a known state when the button is open. Without this resistor the pin will be randomly switching from HIGH to LOW and so reading the button will not be accurate. If you use too high of a resistor value as a pull-down then it will not be strongly pulled to ground and electrical noise could still cause the pin to read as HIGH even when the button is not pressed. 10K is a conservative pull-down resistor value that should be quite reliable under normal circumstances. In a situation where you have the button on a long wire (which acts as an antenna) and lots of electrical noise, you might use an even lower resistor value. A low resistance pull-down resistor will cause more power consumption than a high resistance one so for a battery power application it’s a good idea to make sure you’re not using a lower value than needed.

How would we know what resistor to select when building our own project?

By learning what the resistor is doing, then you need to know how much it is doing and then calculating by ohms law what the value has to be.

With digital electronics however resistor values are not too critical most of the time and a wide variety of values can be used. For a beginner the two main uses of a resistor are

  1. to limit the current through an LED 220R is standard for this.
  2. to bias an input pin 10K is standard for this.

This tells you about input pins Inputs

If you used a 10000 Ohm resistor the LED would not be lit up at all.

Wouldn't bet on that! :astonished:

A common complaint here is that the LEDs in a project only light up dimly, which almost always means that the pins have not been defined as output so that when written HIGH, the internal pull-ups of approximately 47 k are enabled.

We are talking about modern LEDs, not those in my parts bins from 30 yeas back. :grinning:

You're right. An older LED is very dim but some more recent decent quality ones are actually fairly bright.

recent decent quality ones are actually fairly bright.

Especially the white ones where often with 1K they are still too bright to look at directly.