# [Solved] General quick doubts about Resistors, LEDs, Switches

Hello all,

I'm sure you get a lot of these posts, but even after searching around I'm not really confident in my conclusions enough that I can part without some sort of confirmation from more experienced people.

I'm new to electronics in general and Arduino in particular. So I've been reading and following tutorials but I still can't understand some things about resistors. The points in which I need help are in bold for easy identification.

Let's say I have a Red LED with forward current and voltage: 2V, 20mA

Assuming I connect it to a 5V pin in the Arduino, I should use a resistor of about 150 Ohms for that LED, correct? Reasoning: R = V/I = 5 - 2 / 20ma = 150 Ohms

If I don't have a resistor with 150 Ohms, would I be safe using any resistor with more Ohms than that (provided the LED still shines)?

(I don't understand why the "Getting Started with Arduino" guide tells us to connect an LED directly to one of the pins, but I'll assume it's just a quick test)

If I use an RGB LED (let's simplify and assume each color has the same specs as above), should I use 3 150 Ohms resistors, one in each input?

Now another thing that I find strange is that switch products like Pushbuttons and DIP Switches do not generally have a datasheet (just physical dimensions), and I thought they wouldn't need any resistors because they just stop or connect the circuit. Imagine my surprise when the tutorial told me to use a 10k Resistor.

So if I understand correctly, we need to use a big resistor like that to make sure the voltage is fixed on a determined state (depending on where we put the resistor). However, in my first tests I connected an output pin on HIGH to a pushbutton switch (without any resistor), connected to an LED (with the resistor I'm using for the LEDs) and it worked. Does this break the buttons? Why exactly do I need the resistor?

Thank you so much for your time and I'm sorry if these questions are answered time and time again. All I could find were tidbits of information and since I'm not fond of burning equipment I thought I'd ask for confirmation of my findings.

Let's say I have a Red LED with forward current and voltage: 2V, 20mA

Assuming I connect it to a 5V pin in the Arduino, I should use a resistor of about 150 Ohms for that LED, correct? Reasoning: R = V/I = 5 - 2 / 20ma = 150 Ohms

So far so good.

If I don't have a resistor with 150 Ohms, would I be safe using any resistor with more Ohms than that (provided the LED still shines)?

Yes.

If I use an RGB LED (let's simplify and assume each color has the same specs as above), should I use 3 150 Ohms resistors, one in each input?

Yes. However, RGB LED's generally have different specs per color so you'll have to adjust the resistors accordingly.

Now another thing that I find strange is that switch products like Pushbuttons and DIP Switches do not generally have a datasheet (just physical dimensions), and I thought they wouldn't need any resistors because they just stop or connect the circuit. Imagine my surprise when the tutorial told me to use a 10k Resistor.

Now this is a different story. You are confused because you used the same device (switch) for two different purposes. In one application, you can put the switch in series with the 150 ohm resistor and LED and have it turn the LED on and off. No extra resistors are required.

In another application, a switch is used to tell the Arduino whether it is pushed or not. That is, you use digitalRead() to sense the state of the switch. In this case, you do want a 10k resistor (or so) from 5V to the switch (and the other side of the switch connects to ground/0V). The center node (where 10k resistor and switch meet) goes to an Arduino input pin. Then, when the switch is pushed, this node is 0V and digitalRead() returns LOW. Otherwise, the 10k resistor keeps the node near 5V and digitalRead() returns HIGH. Without the 10k resistor the node would "float" (be at an indeterminate voltage) and you may not read a solid LOW or HIGH when the button is not pushed.

Now, the Arduino actually has 10k resistors built-in to each pin (called "pull-up resistors") which can be enabled by writing a 1 to the pin (i.e., digitalWrite(pin, HIGH);) when the pin is an input. So you don't even need the external 10k resistor in this case.

Hope that helps a bit...

-- The Aussie Shield: breakout all 28 pins to quick-connect terminals

Thank you very much, that clears the confusion I had! Going to try those built-in resistors then.

Just a picky clarification - the built-in pull up resistors are not 10k, they are between 20k and 50k.

MarkT: Just a picky clarification - the built-in pull up resistors are not 10k, they are between 20k and 50k.

Thanks :) I've tried them and they worked as expected.