Once of the important things to do when you play around with electronics is to make sure that you are safe-guarding your electronic components from over current.

The most common way to do that is by adding a resistor in series. You can calculate the value of the resistor needed for safe operation by using Ohm’s law.

But, when I was getting started with electronics and Arduino, I always found it difficult to understand how a particular value of resistor is recommended in tutorials, even though you will be getting a different value when you try to apply Ohm’s law yourself.

It took me quite sometime to understand the logic behind it and I thought of explaining it here, so that it is helpful for people who are also just getting started.

## Protecting Arduino Pin from over current

Let’s consider the simple Blink example in Arduino. This is most probably the first program you might have tried when you are getting started with Arduino.

If you look at the circuit, you will find that you are asked to connect a 220 Ohm resistor in series to protect the Arduino pin and the LED. But it is not mentioned how or why this value is chosen.

Now let’s try to calculate the value ourself. You need to be familiar with Ohm’s law, if you are not, then read this excellent tutorial by Evil Mad Scientist, which explains the whole concept very clearly.

If you have read the above tutorial, you will now know that a typical red LED has a voltage drop of 1.8V and a current of about 25mA. The Arduino Pin has an output voltage of 5V.

Let’s use these values in our calculation.

V = (power source) – (voltage drop) = 5V – 1.8V = 3.2 V

I = 25 mA

We need to find R.

R = V/I

Substituting the values, you will get

R = 3.2/0.025 = 128 Ohms.

We need to use 128 Ohm resistor, but the tutorial asks us to use 220 Ohm, which is almost double.

## Practical easiness over theoretical correctness

It took me quite sometime to figure out why 220 Ohm is recommended over 128 Ohm.

It is an apt example of choosing practical easiness over theoretical correctness. Engineers being practical people always prefer practical solutions over theoretical ones ðŸ˜‰

If you try to buy resistors from a local hobby shop, you will find that the resistors are available in the following values.

`{ 100, 220, 470, 1000, 2200, 4700, 10000 }`

These are the standard values and are easier to find rather than other values.

If you look at the values, you will find that 100 Ohm is less than 128 Ohm (that we calculated) and is quite risky. The next higher easily available value is 220 Ohm.

When you substitute `R=220`

in the equation `I=V/R`

I = V/R

I = 3.2/220 ~= 14mA

You will get the value of the current to be around 14mA. LED’s operate between 10-25mA. Also, since LED’s are non-linear devices, the difference in the current from 14mA to 25mA doesn’t necessary mean a proportional difference in the brightness. In most cases, you may not even be able to tell the difference.

So, choosing 220 Ohm instead of 128 Ohm is purely because of practical easiness. If you have bought a getting started kit with Arduino or a pack of assorted set of resistors, you are more likely to find a 220 Ohm rather than 128 Ohm.

As, I mentioned before, the Blink example is most probably the first circuit that people are going to try and if you ask them to use a non-common resistor, then most probably they are not going to find it and might stop right there itself, instead of going forward. And that’s the reason why they have recommended 220 Ohm.

Arduino, being a platform for beginners, it is perfectly fine that they tried to simplify things for you. But once you start to grasp things, you might have to dig deeper to understand why a particular circuit or sketch is build in a certain way.

Happy hacking ðŸ™‚

RoyceHey there, thanks for the write up. I’m a HW newbie and just starting out with Ardunio. I want to buy resistors from Radio Shack, but the 1st question I’m asked is which one? I know I need 220ohms, but then I’m asked how many watts an tolerance??? I bought 1/2 watt and 5% tolerance, but I don’t know if that’s correct. I see lots of write ups about ohms, but nothing about watts or tolerance for resistors.

Any guidance on that?

Regards

SudarPost authorWhere are you planning to use these resistors?

If you are just buying them for hobby use, then tolerance or watt may not have a huge difference.

rickThe wattage ratings of the resistors tells you much power the resistor can handle. If the resistor wattage rating you have is less than the power level where you want to used the resistor in a circuit, the resistor will get damage or burnt. The resistor wattage ratings comes standard as 1/8 watt, 1/4 watt, 1/2 watt, 1 watt, 2 watts, and so on. You want to get the higher wattage ratings than the expected wattage value you want to use your resistor in a circuit. For example, if the resistor in a circuit require a power that is below 1/4 watt and above 1/8 watt, but you used a smaller value like 1/8 watt value, that 1/8 watt value resistor will not be sufficient to handle the required power, and it will get damage or burnt. The important thing to remember is that you need to used a higher wattage value resistor than the expected wattage value you want to use the resistor in. The formula for finding the power are: Power = Current times Voltage, Power = Current Squared times Resistance, Power = Voltage Squared divided by Resistance.

The tolerance value tells you the range of values the resistor will fall in above and below the stated value. For example if you have a 220 ohms value resistor and it is rated as 5% tolerance it means that the resistor value will be somewhere 5% above and 5% below the stated 220 ohms value.

5% of 220 is equal to 11. So 220 – 11 = 209. And 220 +11 = 231. So a 5% tolerance resistor will have is value between 209 ohms and 231 ohms.

FrankGRick, Thanks for the good clear information, butI think you didn’t actually ansswer Royce’s question. What wattage resistor does he need to use?

As you say watts value is current times voltage, so with the shown calculation of 14 ma with 3.2 volts across the 220 ohm resistor, that would be 14 x 3.2 or about 45 milliwatts. 1/8 watt is 125 millamps so that is all that is needed, more than enough.

OriVery clear writen

Thank you

Ori

nitsh560k

Where do we use it

ChrisThanks for your explanation!

Helped me a alot!

OscarExcellent post! ðŸ™‚

Sushmitathanks its very helpful

AjiteshIs it necessary to connect arduino to laptop after uploading the code to blink a led ??

Can I power my arduino with a battery instead of connecting it to laptop after uploading the code in arduino??

Mihai S.Arduino Mega has power conector so you can use that when away from computer. Also, the USB cable used for programming could be connected to a portable power bank for cell phone charging thus having power without a PC.

Damo4320Sure can

john errington MScSorry, I read the article its boll.. incorrect in many respects.

Firstly an LED has a forward voltage that depends on the current through it; and that is controlled not by the LED but by the voltage across the series resistor. So AN LED DOES NOT HAVE A CURRENT OF 25mA.

The safe forward current for most 3mm and 5mm LEDs is typically 20mA.

The brightness depends on the forward current, and modern LEDs give a clearly visible indication in daylight down to about 2mA.

Provided your arduino is a 5V type you calculate 5V – 1.8V (LED) = 3.2V

Using V/I=R we get 3.2/0.02 = 160 ohms.

The nearest value in the most common E12 (10%) resistor range is 180 ohms.

The nearest value in the E24 (5%) resistor range is 160 ohms.

A resistor of 220 ohms gives a current of about 15mA which is a safe forward current.

However a NANO has around 20 ports so you COULD drive 20 LED’s. That would draw 300mA

So a 220 ohm resistor is not “practical easiness” its just a very workable sensible compromise.

Rama shankerrst study: classe 12 and classe 10 solutions-Hi friend classe 10 hindi solution and class 10 physics solution clas

Class 12 physicssolution and class 12 english study yeh sab subject hum aapko aapne bhasha mai btayenge to aap es trah online read ker sakte hai hindi mai