Go Down

Topic: Blinking led (Read 243 times) previous topic - next topic

hassanbosha20

What is the importance of the resistance in a simple blinking led circuit ?

Digital pin as output then resistance and led series into a ground
Does it protect the arduino or it protects the led from high current ?

raschemmel

Without the resistor the led will  be damaged in a few milliseconds at most.

amdkt7

Rather important. It protects both devices. The digital pin is rated for 20ma continuous, and up to 40ma for a short pulse (not recommended to ever exceed 20ma).

The led might be able to handle much more than 20ma, depending. You need to know the forward voltage drop and the leds current rating to properly pick a resistor value.

However, most of the time you can assume no voltage drop and simply divide 5 volts by 20ma and get 250 ohms. In most cased you would actually result in a lot less current in the led, but often will be bright enough anyway. I generally calculate using the datasheet on the led, and aim for about 5ma. I will adjust the value later if I find I need it brighter or dimmer.

syedamerali

Excellent reply by amdkt7. I would just like to add that an LED is a constant current device and it is the series resistor which regulates the current and keeps it constant.

DVDdoug

Blinking or not, in the "real world" it will probably "work" without blowing the LED or your Arduino but you are exceeding the specs for both the Arduino and the LED and it's EXTREMELY BAD PRACTICE and if you publish your design on the Internet people will know that you don't know what you're doing!  Some beginners have done this and they'll say, "See it works fine!"   Ignore that if you run-across it!   LEDs should ALWAYS have some kind of current limiting (or "current-control").
 
Yes, the resistor limits current.   Are you familiar with Ohm's Law?  Current (in amps) = Voltage/Resistance.

LEDs are "a little odd" because (like all diodes) they are extremely non-linear.   That means their resistance changes with voltage.  Below the operating voltage ("forward voltage" for a regular diode) they have high resistance, very-low current flows, and they may not light-up at all.    Above the rated operating voltage resistance drops, you get excess current, and the LED fries.  

For example, if you connect an LED without a resistor to a car battery (capable of hundreds of Amps) you'll kill the LED and the LED might literally explode!   With the proper resistor you'll get a few milliamps and everything is cool!   

Ohm's Law is a law of nature (with man-made units-of-measure) and it's always true but it's not that helpful directly  with LEDs because of the varying resistance.     So, we have to use Ohms Law for the resistor-only to determine the resistor value.  

You can find LED resistor calculators online but I'll explain how it works...
First, you need a couple more "laws"...  One of Kirchhoff's Laws says voltages divide among series-connected components (relative to their resistance) and one says the current is the same through series-connected components.

For example, if we have an LED rated for 2V at 20mA and we are going to apply 5V, we want 2V across the LED, 3V across the resistor, and 20mA through both.   So we simply use Ohm's Law to find the correct resistance for 20mA at 3V...   3V/0.02A = 150 Ohms.       Because of their non-linear nature the voltage across the LED "magically falls into place" and with a higher-value resistor you'll still have about 2V across LED and 3V across the resistor (but with less current).        

polymorph

It is improper terminology to describe the V/I of a nonlinear device as "resistance".

Ohm's "Law" isn't really a law. It is a description of a set of special devices where the ratio of voltage to current stays constant over a wide range. The ratio of V to I, or V/I, we call "Ohms".

So if 100V applied to a device causes 1A of current, that is 100/1. If we put 10V across it and now 0.1A flows, the ratio is still 100 to 1. If that holds true over a wide range of voltage and current, we call it a resistor.

Then we say "Ohm's Law" applies to devices we call resistors.

You can put two or three or more resistors in series or parallel, and calculate the total circuit's equivalent voltage to current ratio. I can put a volt across each resistor, measure the current, and know that the ratio is the same over a wide range, but only because we previously defined resistors such that only devices that display a constant V/I ratio are called resistors.

A simplification of an LED or other diode is that it is more of a constant voltage device. It is not only misleading but wrong to call this a changing resistance. There are certain aspects of the model of a diode or LED that may be named things like "bulk resistance", or ways to take advantage of certain characteristics of a PIN diode to make it act like a current variable resistance but only under certain limited, special circumstances.

I'm trying to say that Ohm's Law only applies to devices that Ohm's Law applies to. It is like saying that the speed limit applies only to people who obey the speed limit, then calling it a Speed Limit Law. It is really more of a rule of thumb - for devices which maintain a constant V/I ratio, they maintain a constant V/I ratio. Calling it "Ohm's Law" is just a way to remind us this holds true for things we call resistors. Which we only call resistors because they display a constant ratio of V/I.
Steve Greenfield AE7HD
Drawing Schematics: tinyurl.com/23mo9pf - tinyurl.com/o97ysyx - https://tinyurl.com/Technote8
Multitasking: forum.arduino.cc/index.php?topic=223286.0
gammon.com.au/blink - gammon.com.au/serial - gammon.com.au/interrupts

raschemmel

Quote
It is like saying that the speed limit applies only to people who obey the speed limit, then calling it a Speed Limit Law. It is really more of a rule of thumb 
It is a rule of thumb : Posted speed = MINIMUM speed...

If you see something , say something .
If you see someone breaking Ohm's Law call the Ohm Police.

amdkt7

I imagine the OP is a bit overwhelmed with the advanced technical discussion. He wanted to know if a resistor is really needed and which part it protected. He got a long discourse in how to calculate resistor values and how Ohms law applies. I suppose it may have helped some others to improve their understanding, but I think that most of it went well over his head. Not that he is not capable of understanding, but he is clearly a novice.

raschemmel

He can always get a bag of leds and a bag of resistors and a tras can and learn the hard way

hassanbosha20

Yes, i just needed to know which part does the resistor protect and how ?
As Amdkt7 said

CrossRoads

Resistor protects the IO pin, keeps it from sourcing/sinking more than the 20mA recommended current.

Formula:
(Vcc - Vf - Vio pin)/current = resistor. Vio pin is the voltage across the Arduino IO transistors that connect a pin to Vcc or to Gnd. Vf is the voltage across the LED when it turns on.
So for arduino:
(5V - 2.7V - 0.7)/.02A = 80 ohm

Fill in the Vf of your particular LED. 20mA for modern LEDs will be really bright.
If Vf = 2.5V and current is reduced to mA, then:

(5V - 2.5V - 0.7V)/-0.01A = 180 ohm

Vout high might be more than 4.2V for currents less then 20mA, 
Vout low might be lower than 0.9V for currents less than 20mA.
So used Vcc - 0.7 for that part of the calculation.
Vcc may be different (generally lower) when powered from USB due to voltage drop across the USB current protection fuse, and the USB requirement to supply 5V +/- 5%.
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

Go Up