Pages: [1] 2   Go Down
Author Topic: Very basic resistors question  (Read 1135 times)
0 Members and 1 Guest are viewing this topic.
Asnieres sur Seine - France
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I am an old software guy who is trying to (re)learn all of this basic electronics and hardware with Arduino.

I have a pretty basic question, the answer to which will help me in all my future endeavours, it's about calculating which resistor(s) I need for any given sensor or output device I connect to my Arduino.

Let's say I'm plugging in to the 3.3V output on my Arduino...

I have a LED which says "Uf 2V lf 20mA" and another which says "Uf 3V lf 20mA"

How do I figure out what size resistor I need to plug in? What's the magic formula I need to apply?

And I always plug the resistor in to the GND connector of the LED (going back to the GND pin on the Arduino) right?

Many thanks.
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6133
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

When LEDs have enough voltage dropped across them (their "forward voltage"), they (effectively) turn into short circuits.  So you are using the resistor to limit the current flowing to whatever the max current of the LED is (or what level of current you want).

So you use Ohm's law to calculate the resistor value.   I explain here:
http://www.cmiyc.com/tutorials/led-basics/
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Asnieres sur Seine - France
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you for the tutorial. I learned a lot!

The first thing I learned is that the "lf" in my LED sticker stands for Forward Current.

Would you know what the "Uf" stands for?

...

I got a bit confused when we got to the actual formula part of your tutorial.

I see the +5V output and I see that we want to calculate R_LIMIT for 20mA.

I don't see how you jumped from the +5V above the R_LIMIT to the 3.0V in the R_LIMIT calculation rather than using 5V.

In your calculation 3.0V / 20mA = 150 Ohms. 3/20 = 0.15 so I assume that somehow 20mA gets converted to 0.02 in our calculation. We take 20 and divide it by 1000 as we're working with milliamps?

Why didn't we do 5.0V / 20mA to give us 250 Ohms as we have 5 volts coming out of the Arduino?

I therefore have a (red) wire going from the 5V of the Arduino to the (longer) Anode wire of my LED; a (black) wire going from the (shorter) Cathode wire of the LED to one end of the 150-270 Ohm resistor and another (black) wire going from the other end of the resistor to the GND pin of the Arduino.

My LEDs, except for the RGB ones, only have 2 pins. Where would I attach the wire going from the LED to the digital or analog output pin on the Arduino?
Logged

UK
Offline Offline
Faraday Member
**
Karma: 99
Posts: 4153
Where is your SSCCE?!?!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

The first thing I learned is that the "lf" in my LED sticker stands for Forward Current.

Would you know what the "Uf" stands for?

It's not "Uf", but "Vf", and stands for the forward voltage (Volts, forward).
Logged

Get 10% off all 4D Systems TFT screens this month: use discount code MAJENKO10

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6133
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't see how you jumped from the +5V above the R_LIMIT to the 3.0V in the R_LIMIT calculation rather than using 5V.
When components are in series their voltage drops add up while their current is equal.  --There are only so many electrons.

The circuit in this case is an Arduino Pin, Resistor, and LED.

So if your source (like the Arduino pin) has a voltage of 5V and the LED will drop 2V (its forward voltage), that leaves a 3V drop for the resistor.

Since the parts are in series and you want 20mA to flow through the LED, you use Ohm's Law to calculate the resistance value knowing that WHATEVER the resistor value is, it is going to drop 3V.

Ohm's law says that Resistance is equal to Voltage divided by Current.   We know the voltage drop of the resistor (3V) and the current (20mA).  That gives 150ohms.

Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I am an old software guy who is trying to (re)learn all of this basic electronics and hardware with Arduino.

I have a pretty basic question, the answer to which will help me in all my future endeavours, it's about calculating which resistor(s) I need for any given sensor or output device I connect to my Arduino.

Let's say I'm plugging in to the 3.3V output on my Arduino...

I have a LED which says "Uf 2V lf 20mA" and another which says "Uf 3V lf 20mA"

It's Vf on Uf, for forward voltage drop value.

How do I figure out what size resistor I need to plug in? What's the magic formula I need to apply?
It's (voltage source minus Vf) / If = resistor ohms, so for you two leds:
(3.3 - 2) / .02 = 65 ohms
(3.3 - 3) / .02 = 15 ohms


And I always plug the resistor in to the GND connector of the LED (going back to the GND pin on the Arduino) right?

It's a series circuit (led/resistor) so it doesn't matter if the resistor or led wires to ground, same current flows in only one path. However the polarity of the LED does have to be correct or it won't conduct current
at all.
Lefty


Many thanks.

Logged

Asnieres sur Seine - France
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I understand that Uf should be Vf. But on the LEDs I get they all say Uf

http://snootlab.com/lang-en/leds-10-mm/57-led-10mm-green-diffused.html
http://snootlab.com/lang-en/leds-5-mm/51-led-5-mm-green-20-8x.html

The important thing is that I now understand that these values are forward voltage and what they are used for.

For an output pin of 5V with a LED of Vf 2V and an lf of 20mA I would use a resistor of 150 ohms
(5 -2) / 0.02 = 150

For an output pin of 3.3V with a LED of Vf 3V and an lf of 20mA I would use a resistor of 15 ohms
(3.3 - 3) / 0.02 = 15

As regards the circuit, if I've understood correctly and following the examples I've seen in the books, I run the power from the output pin on the Arduino (3.3V or 5V) to the anode wire of the LED, a wire from the cathode wire of the LED to the resistor (using the calculation above) and a wire from the other end of the reistor to the digital or analog output pin of the Arduino.

I think I am, very slowly but surely, getting there.

I've been following the examples in the books, and blindly plugging in the right components in the right holes, without really understanding why.

Thank you all so much for your explanations.
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I understand that Uf should be Vf. But on the LEDs I get they all say Uf

http://snootlab.com/lang-en/leds-10-mm/57-led-10mm-green-diffused.html
http://snootlab.com/lang-en/leds-5-mm/51-led-5-mm-green-20-8x.html

The important thing is that I now understand that these values are forward voltage and what they are used for.

For an output pin of 5V with a LED of Vf 2V and an lf of 20mA I would use a resistor of 150 ohms
(5 -2) / 0.02 = 150

For an output pin of 3.3V with a LED of Vf 3V and an lf of 20mA I would use a resistor of 15 ohms
(3.3 - 3) / 0.02 = 15

As regards the circuit, if I've understood correctly and following the examples I've seen in the books, I run the power from the output pin on the Arduino (3.3V or 5V) to the anode wire of the LED, a wire from the cathode wire of the LED to the resistor (using the calculation above) and a wire from the other end of the reistor to the digital or analog output pin of the Arduino.

I think I am, very slowly but surely, getting there.

I've been following the examples in the books, and blindly plugging in the right components in the right holes, without really understanding why.

Thank you all so much for your explanations.

Yes you appear to have the calculations all down correctly. However there appears to be an error on your wiring suggestion:

Quote
I run the power from the output pin on the Arduino (3.3V or 5V) to the anode wire of the LED, a wire from the cathode wire of the LED to the resistor (using the calculation above) and a wire from the other end of the reistor to the digital or analog output pin of the Arduino.

It should be one of the two following:

arduino digital output pin of your choice to led anode, led cathode to resistor, other end of resistor to arduino ground pin.
or
arduino output pin of your choice to resistor, other end of resistor to led anode, led cathode to arduino ground pin.

That way writing a digitalWrite(pin#, HIGH); will light the led and a digitalWrite(pin#,LOW); will turn it off.

Lefty
« Last Edit: February 25, 2013, 12:37:33 pm by retrolefty » Logged

Asnieres sur Seine - France
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I now understand that the resistor can be connected on the cathode pin or the anode pin.

If I am running a wire from the digital, or analog, output pin on the Arduino to the cathode wire of the LED I assume it is the digital, or analog, output pin on the Arduino which is sending the current to the LED. If I am using one of these output pins, rather than the 5V or 3.3V pins, how do I know how many volts are going to the circuit and therefore which resistor calculation to use?
Logged

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6133
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I understand that Uf should be Vf. But on the LEDs I get they all say Uf
Source of the confusion is where the datasheet comes from.  European countries tend to abbreviate voltage as "U" while the rest of the world uses "V".  (Another abbreviation is "E".)

Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I now understand that the resistor can be connected on the cathode pin or the anode pin.

If I am running a wire from the digital, or analog, output pin on the Arduino to the cathode wire of the LED I assume it is the digital, or analog, output pin on the Arduino which is sending the current to the LED. If I am using one of these output pins, rather than the 5V or 3.3V pins, how do I know how many volts are going to the circuit and therefore which resistor calculation to use?


For calculation purposes you can just assume a digital output pin set to HIGH will have the same voltage as the Vcc value powering the chip, so +5vdc for a 5 volt board and +3.3 volts for a 3.3 volt board.

Note your above:

Quote
If I am running a wire from the digital, or analog, output pin on the Arduino to the cathode wire of the LED I assume it is the digital, or analog, output pin on the Arduino which is sending the current to the LED.

Yes, however:

Normally one wires the led anode to the output pin and the cathode/resistor end to a ground pin so that a digitalWrite HIGH will turn on the led. If you wire the cathode to the output pin then the other end of the led/resistor must wire to the +5V pin and the led will only light if you set the digital output pin LOW.

Lefty
Logged

Asnieres sur Seine - France
Offline Offline
Jr. Member
**
Karma: 0
Posts: 53
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you again for your detailed and helpful replies.

Quote
For calculation purposes you can just assume a digital output pin set to HIGH will have the same voltage as the Vcc value powering the chip, so +5vdc for a 5 volt board and +3.3 volts for a 3.3 volt board.

Is an Arduino Uno a 5 volt board or a 3.3 volt board?

Would all of this work the same if I go through an analog port instead of a digital port?
Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 361
Posts: 17263
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you again for your detailed and helpful replies.

Quote
For calculation purposes you can just assume a digital output pin set to HIGH will have the same voltage as the Vcc value powering the chip, so +5vdc for a 5 volt board and +3.3 volts for a 3.3 volt board.

Is an Arduino Uno a 5 volt board or a 3.3 volt board?

It's a 5 volt board.

Would all of this work the same if I go through an analog port instead of a digital port?

If you mean pin instead of port, then yes the analog input pins can be used as digital input or output pins. You just have to set the pin mode and output value using the pin mode and digitalWrite commands.
Lefty


Logged

0
Online Online
Edison Member
*
Karma: 7
Posts: 1235
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I use these quick and easy calculators:


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


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


Texas, land of the free, home of the stupid
Offline Offline
Sr. Member
****
Karma: 5
Posts: 267
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Derek:   You might want to look up Thevinin and Kirchoff.

Good luck and have fun
Logged

Pages: [1] 2   Go Up
Jump to: