About the position of Resistors in project 1 and 2

Hi, I'm totally new with electronics so maybe this question will be sound silly. In the first project (Get to know your tools) We put the resistor before the LED but in the project 2 (spaceship interface) the resistors are connected after the LEDs. As It's explained in the book the resistor serves to downgrade the current and to prevent the LEDs from burning. Can anyone explain the difference?

Thanks.

PS: Sorry about my poor English.

In a case like this it does not make a difference whether the resistor is on the anode or cathode. It limits the current through the circuit either way. Think of it as a "degree of freedom".

Once you have more parts in play, or more complex active parts, there are fewer "degrees of freedom".

-br

And if I may elaborate a little on billroy's reply.... the reason it doesn't matter is that in a so-called series (one after the other) connection like this, the current has only one possible path. It has to go through both the resistor and the LED, and has to be the same through both since it has nowhere else to go.

Given that the resistor is restricting the current through itself so to speak, the same restricted current goes through the LED as well, and so it won't matter which is first in line. It's a bit like standing on a hose pipe.... the restriction to the water flow applies all along the pipe.

If there's a branch in the wire or pipe, the so-called parallel circuit, well that's another thing altogether.

Thanks!

Hi all,

I have a related dude about this project and the resistor's value. If we consider a IF = 20 mA and a VF = 2,6 V (like typical values for a led), I figurate up we have to use a 120 ohms resistor. Why it uses a 220 ohms resistor in the project? I can imagine some possible answers but I have dudes because this guide doesn't include the calculations.

(Excuse my english).

Thank you arduineando for asking that question and JimboZA for answering it so clearly. This is exactly the reason I came to this forum today to find out the reason for this.

In actual fact, I thought it was a mistake in the book and in fear of blowing the LED, I just wired up the resistor before the LED. In my mind it makes sense then that the resistor will reduce the amount of electricity getting to the LED, if you put the resistor after the LED, then in my head, the LED will get a big hit of power, before it get's to the resistor and that will then "slow" down the electricity but the LED should (Again in my understanding of it) have already blown.

Actually using the analogy in the book, if the energy is the rocks falling and the LED is a tree half way down the mountain, then the resistor is a few more trees lower down the mountain, when the rocks start to fall, they will be at full power when the hit the first tree and only will flatten that first tree (The LED), then as the rocks keep falling down the hill, they hit the second set of trees (The resistor) and only then are they slowed down enough to not completely flatten them all. Actually although I can accept what is being said, it still doesn't make any sense.

Anyhow, I've loads of questions as this is all very confusing, but again thank you for asking this question as this is one of the ones that has really got me confused.

Analogies are often dangerous...

Rather think of the resistor as a restriction of some sort- since water in a pipe, or electrons in a wire, are not compressible, it's almost like a solid "rod" of water or electrons. If the molecule of water or electron at the front is not moving, or its movement is restricted, then the one at the back's not going anywhere either. But that's just an analogy as well.

But it's easy enough to test- hook an ammeter up in series with the resistor and led, or just for fun a couple of resistors, and swap the order around. As long as you keep the same components in the series circuit, and the battery keeps to the same voltage, you'll see the same current regardless of the sequence of parts.

Regarding the 220 vs 120, well as long as the resistor is bigger than the value you calculated, you're safe and the lower current will safeguard the led, which will just not be as bright.... up to a point of course, too big a resistor and the led will be too dim to see.

JimboZA:
Analogies are often dangerous...

Regarding the 220 vs 120, well as long as the resistor is bigger than the value you calculated, you're safe and the lower current will safeguard the led, which will just not be as bright.... up to a point of course, too big a resistor and the led will be too dim to see.

I understand that the bigger resistor is the lower current will but I miss some explanation about how to choose the resistor's value.

I understand that the bigger resistor is the lower current will but I miss some explanation about how to choose the resistor's value.

Ah ok....

You have to make sure you only have Vf available to the LED, and need to lose any other voltage from the supply, across the resistor.

You know a few things: the voltage supplied Vs, the voltage the LED can take Vf, and the current I.

You need to lose the difference in the voltages across the resistor, call that Vr: so Vr = Vs - Vf

Apply Ohm's Law to the resistor, where it's R we need to find: R = Vr / I = (Vs - Vf) / I.

I don't know Vs in your example, let's say it's 9v for example... then we need to lose 9 - 2.6 = 6.4v across the resistor so R = 6.4 / .02 = 320.

So to summarise, you need to apply Ohm's Law to the resistor, not the LED, and the resistor needs to drop the surplus voltage.

R = (Vs-Vf) / I

Good explanation. Thank.

I'm just starting with Arduino and have a quick question on project # 2 (Spaceship Interface): Why do we need to add a 10k-ohm resistor from ground to the switch pin? Is this to protect the switch or is the power flowing from the switch through the resistor then onto the other resistors? I guess I'm just trying to understand the flow of the electricity and how it travels through each resistor.

John I don't have a starter kit, so I don't have the circuit in front of me, but....

The resistor you mention is a so-called "pull-down" since it pulls one side down to 0v. (If you stick it on the other side, to 5v, then no surprises it's a pull-up.

In a digital world, pins need to be at either a high or a low state, 1 or 0, 5v or 0v. If a pin isn't connected to anything, then it's voltage can literally be anything, due to interference from passing asteroids or who knows what. So, since when we read our pin we need to be able to rely on it being one way or the other, not some random "floating" value in between, we pull it to one or other side with a resistor. So if you read the switch when the button is not pushed, it will read 0v reliably in your case due to pull-down resistor.

Then when you hit the switch, the wire to 5v from the switch hooks the pin to 5v which is what you want when the switch is pushed.

Lastly, why use a resistor at all, and not just a wire? Well look at your circuit and you'll see that when the switch is pushed, there is a path from 5v thru the switch thru the resistor to 0v. Without the resistor, that path would be a dead-short and BOOM.

)EDIT- also with no resistor, both the 5 an 0 sides of the switch will be competing and the switch in the middle of the divider with 0 resistance on both sides would then get 2.5v, but the short would have melted something first. But anyhoo, with the resistor on one side, the other side "wins" and the pin gets almost all the 5v.)

HTH?

Jim

Being a total newb at electronics, I wondered the same thing when looking at these 2 projects. Thanks for the answers! I want to get through some more projects and not to burn up my board just yet :slight_smile:

JimboZA:
John I don't have a starter kit, so I don't have the circuit in front of me, but....

The resistor you mention is a so-called "pull-down" since it pulls one side down to 0v. (If you stick it on the other side, to 5v, then no surprises it's a pull-up.

In a digital world, pins need to be at either a high or a low state, 1 or 0, 5v or 0v. If a pin isn't connected to anything, then it's voltage can literally be anything, due to interference from passing asteroids or who knows what. So, since when we read our pin we need to be able to rely on it being one way or the other, not some random "floating" value in between, we pull it to one or other side with a resistor. So if you read the switch when the button is not pushed, it will read 0v reliably in your case due to pull-down resistor.

Then when you hit the switch, the wire to 5v from the switch hooks the pin to 5v which is what you want when the switch is pushed.

Lastly, why use a resistor at all, and not just a wire? Well look at your circuit and you'll see that when the switch is pushed, there is a path from 5v thru the switch thru the resistor to 0v. Without the resistor, that path would be a dead-short and BOOM.

)EDIT- also with no resistor, both the 5 an 0 sides of the switch will be competing and the switch in the middle of the divider with 0 resistance on both sides would then get 2.5v, but the short would have melted something first. But anyhoo, with the resistor on one side, the other side "wins" and the pin gets almost all the 5v.)

HTH?

Jim

I assume that in this case we could use any resistor.. right? Or does it have to be a 10 kOhm resistor?