Learn to code

Arduino Home

Lessons 1
Arduino - Getting Started
Lessons 2
Arduino - Basics
Lessons 3
Arduino - Serial Communication
Lessons 4
Arduino - Digital / Analog
Lessons 5
Arduino - Visual Output
Lessons 6
Arduino - Motor Control
Lessons 7
Arduino -LCD Displays
Lessons 8
Arduino -LCD Displays

Understanding basic electronics and resistance for Arduino

in Arduino Getting Started

To understand how electronic circuits work and how to use them. There are some basic definitions you need to learn.

Sensors: These are components that convert other forms of energy into electrical energy that you can read. Switches, knobs, potentiometers, light, and motion sensors fall in this category.

Actuators: convert electrical energy into other forms such as light bulbs, motors, and LEDs are all actuators.

Electricity: this is the flow of electrical energy through conductive materials. An electrical circuit consists of two elements: a power source and components that transform electrical energy into other forms of energy.

Electronics: electronics refers to reading changes in electrical properties as information. For example, a microphone changes sound pressure waves in the air into changing electrical voltage. The process of changing energy into another is called transduction. Devices that enable this are called transducers.

To use transduction with Arduino, you must learn something about electricity. Therefore some definitions are given below to understand a few things about electricity. After that, we will look into some electrical properties and components and the relationship between some of the terms.

Voltage: is a measure of the difference in electrical potential energy between two points in a circuit. Voltage is measured in Volts.

Current: a measure of the magnitude of electrons flow through a particular point of the circuit. This point is measured in Amperes or Amps. Since the current we are using is low with Arduino Boards, we will code most of the time with MilliAmps (mA).

Resistance: is a measure of the material’s ability to oppose the flow of electricity. Resistance is measured in ohms.

Resistors: resistors resist but do not block (totally) the flow of electricity. They are used to control the flow of current. Current can move either way through a resistor, so it doesn’t matter which way you connect the resistor in a circuit. Their resistance measures resistors in ohms (Ω), often seen as kilohms ().

Resistance: Ohm’s LAW

One important aspect of electronics is to make sure that you protect your electronic components from over current. The most common way tot hat is by adding resistors. It is essential to understand the method to determine the resister that is needed. Therefore, Ohm’s it is wise to learn more about Ohm’s Law.

Every circuit that we will make must have a source of electrical energy and a load that uses that energy. All of the electrical energy in a circuit has to be used by the load. The load will convert that energy into some other form of energy.

A circuit with no load is called a short circuit. In other words, the power source feeds all of its power through wires back to itself. Your Arduino board or components may melt or blow up.

Figure LED with battery – this circuit is not right!

The figure a very simple circuit consisting of a LED and a battery. The battery is the source, and the LED is the load. The electrical energy coming from the battery is converted to heat and light energy by the LED. All the energy is used in the process. However, the LED cannot take the voltage produced by the battery. (5V is supplied while the LED can handle 2V). How can we not overload the circuit? The answer is quite simple. We can use Ohm’s Law to figure out what kind of resistance we need.

Ohm’s Law : V = I x R

V = Voltage

I = Current

R = Resistance

To get the V in the formula, we need to know two things. The voltage of the power supply and the voltage of the load (led).

Led with resistor

Figure 2. The correct way to connect a LED to an Arduino Uno Board with Resistor.

The Arduino Uno Board will provide 5v of power, and we are wiring a LED to the power source with a resistor. The Arduino board itself receives power from a USB connecter or a dc power supply.

In any loop of the circuit, the voltage must be balanced: the amount voltage generated = the amount used.

So what does this have to do with Forward Voltage? LEDs have a characteristic called “forward voltage,” which is on the datasheet as VF. This forward voltage is the voltage “used” by the LED at a certain reference current. In the circuit above, 5V is one part of the loop, and the other half must use the 5V (to ensure the balance).

Whenever a LED is on, the voltage is used somewhere between 1.85V and 2.5V. So let’s assume 2.2V as an average. Standard red, orange, yellow, and yellow-green LEDs have Vf of about 1.8V, while pure-green, blue and white have a Vf of about 3.3V

Check the datasheet of your LED to make sure you choose the right voltage Foward

If we subtract the Forward Voltage(2.2V) from the power source (5V) we are left with 2.8V. This is the voltage that must be absorbed by the resistor to create the balance in the circuit.

5V (power source) – 2.2V (LED forward voltage) = 2.8V

The next part of the equation is to know the I, which is current, to drive the LED. LEDs have a maximum current (If or Imax on the datasheet). This is often around 25 – 30mA. Slightly under the maximum, we choose our value. Let’s say 20mA.

Note: You can always give an LED less current. Running the LED near its maximum gives you maximum brightness. If you choose to dim the LED, it will cost power dissipation (heat) and battery life (if you use a  battery).

So we are choosing 20mA as the desired current for the LED. With this determined, we can pick a resistor.

2.8 (V) = 20mA(I) x R or rephrased 2.8(v) / 20 mA(I) = R

If you are using mA, convert to A by dividing by 1000.

2.8 / 0.020 A  = 140

When we solve this, number 140 is returned. This 140 Ω or 140 ohms. We end up with a resistor value of 140 ohms.

Resistors are usually available in values such as 10 Ω, 12 Ω, 15 Ω and multiplies (150 Ω, 1.5 KΩ, 15KΩ)

So if the resistor value that is calculated is not a common value, such as 140Ω, we usually pick the next higher number. In our case, that will be 150Ω.

The brightness of the LED is controlled by the current. So, to dim an LED, we need to reduce the current. Recall Ohm’s Law:

V = I x R

Resistor value = (Vsupply– VF)/ IF

Resistor Value = (Power Supply – Forward Voltage) / Current

Thus we can deduce the brightness (current) by either decreasing the voltage or increasing the resistance. You can try this by wiring a much bigger resistance, instead of the 140 ohms, tot he above example. The brightness of the LED will be far less because the resistance is increased. Or you can use the 3.3V pin on the Arduino Uno Board instead of the 5V pin.

So what if we wanted to attach more LEDs to one pin. We can this in series or parallel.

LEDs in series

Figure 3, LEDs in series with one resistor

Can we use multiple LEDs in a string together? Yes, you can use the following formulas.

When resistors are in series, the voltage drops across each resistor, and the total resistance is equal to the sum of all the resistors:

Resistor Value = (Vsupply– (VF x number LED)/ IF

Resistor Valie = Power Supply – (LED voltage x number LED) / Current 

The first side of the equation must be >0. With a 5V supply and 2.2V forward voltage for the led, the maximum of LEDs that can be turned on is 5V / 2.2V = 2

When we subtract the two LEDs forward voltage from the 5v supply, we end up with 0.6V that needs to be resisted by the resistor.

5V – (2.2 x 2) = 0.6

0.6V / 20mA = 30 Ω

In the setup above, with 2 LEDs connected in series. The total voltage is divided in the circuit since it drops with the resistor and the load it flows through. Therefore we need to multiple the forward voltage in the equation by 2 (LEDs).

We can only have 2 LEDs in series with our 5V power source. But we can connect more to the power source if we hook them up in parallel.

LEDs in Parallel with own resistor

Figure 4. LEDs in parallel with common resistors.

In this circuit, we have connected LEDs in parallel with a common resistor. Supply Voltage is 5V, The Forward Voltage (VF) of LED’s is 2.2V, and the forward current (IF) is 20mA each.

For resistors in parallel, the voltage across them is equal. However, the current is divided. The divided current across parallel resistors is equal to the total current.

I1 + I2 = Itotal

To be able to determine the resistor value, we need to take into account the number of LEDs and their forward Voltage.

Resistor Value = (Vsupply– VF)/ IF x number of LEDs

Resistor Value = (Power Supply – Forward Voltage) / Current x Number of LEDS

If we apply this to LEDs in parallel with a common resistor, the following resister value is derived.

(5 – 2.2) / (0.02 x 4) = 35 ohm

We will show how you can control the voltage output with code written on the Arduino microcontroller board in upcoming tutorials.

Hopefully, you will now be able to calculate the resistor value that you need for your project.

But remember:

Resistors divide voltage when in series and divide amperage when in parallel.

Theory versus practical implication

as stated before, in many tutorials, 220 ohms is used for the “blink a LED project”.

It took me some time to understand why 220 ohms is used/recommended instead of the 140 ohms we calculated above. If you buy a resistor from your local microcontroller shop, they usually sell the common resistor values. There is a big chance that the calculated resistor value is not available in our case, 140 ohms.

Be cautious about choosing a resistor value that is below the calculated resistance.

When we choose 220 Ohm for the circuit is a bit higher.

When we substitute R = 220 in the equation I = V/R

I = 2.8/220 = 13mA

The current that the LED receives is around 13mA. LEDs operate between 10-25mA, according to the datasheet. The difference in the current from 13mA to 25mA does not mean that there will be a proportional difference in brightness. In most cases, you will not even tell the difference.

So, choosing 220 Ohm instead of 140 Ohm is pure because of practical easiness. If you have bought a getting started kit for Arduino with resistors, you are more likely to find a 220 Ohm rather than 140 Ohm.

Previous Post
Understanding Power Supplies for Arduino
Next Post
Choosing an Arduino Board
You must be logged in to post a comment.