Adding electronics to your project can be easy if you understand a little bit of math and a few basic principles. These will allow you to manage the electricity flowing in wires and electronic components that you use.

The example used to demonstrate concepts can be applied to old, current, and new projects that you make. The example will use one LED as an active element, but the concepts can be used for other active elements such as buzzers, motors, lamps, relays, etc.

Terminology used is described in the reference document that can be downloaded.

## Step 1: A Minimal Circuit

All of the examples will start with a Battery and then other components will be added for form a Circuit. A Schematic will be used to define the circuit. Let's start with a battery and a Resistor. The real life circuit and schematic are shown above.

Since electricity flows easily through metal objects, the wire (which is made of metal) can be used to route the electricity from the battery to the resistor and back again to the battery without affecting the flow. Note that the wire is covered by an insulator, usually plastic or rubber, to isolate the wire and prevent the electricity from going anywhere else.

## Step 2: Analysis

So, given this simple circuit, what's happening? To find out, follow the flow of electricity. We'll use the KVL tool first.

Start at the negative terminal of the battery and call this 0 volts (this is also referred to as Ground). As we move through the battery to the positive terminal (+), the voltage (E) increase to 3 volts.

Following the electricity through the wire to the resistor nothing has happened to it, so the voltage at the top of the resistor is still 3 volts. Passing through the resistor, it comes to the wire connected to the negative terminal of the battery which is 0 volts.

So passing through the resistor caused the voltage to drop 3 volts. This is where the Ohms's law tool comes in.

The voltage drop was caused by the Current meeting a resistance. When this happens, a voltage change is generated. The change is defined by Ohm's law.

E (voltage drop) = I (current) times R (resistance)

or E = IR. Since we know E (3 volts) and R (1k ohms), we rearrange the equation to solve for I.

E/R = I or 3/1000 = 0.003 Amps = 3 milliamps = 3 ma

That was a lot of math, but what did it tell us? To discover that, we need to look at the properties of the components that we are using. Here are the details:

Battery: 3 volts @ 1000 ma-hr

This battery will maintain a potential of about 3 volts until it has delivered 1000 milliamps of current for an hour.

Resistor: 1k ohm, 1/4 watt

This resistor provides 1k ohms of resistance and can dissipate 1/4 of a watt (250 mw) of power.

With this information and the circuit calculation we can state the following:

1. The battery is supplying 3 ma to the circuit at 3 volts. Given that it has a 1000 ma-hr capacity, it should last about 333 hours.

1000 ma-hr / 3 ma = 333 hr

2. The resistor is dissipating 3 volts at 3ma or 9 milliwatts of power.

Power = E times I = 3 V times 3 ma = 9 mw

This is well below its 250mw limit.

Now, what if different components are used? Say a 100 ohm resistor?

The voltage drop across the resistor is still 3 volts, so the current through it is

3 volts / 100 ohms = 0.03 A = 30 ma

and the power dissipation is

3 volts x 0.03 A = 0.09 W = 90 mw

and is still under the 1/4 W rating. (1/4 W = 250 mw)

But now the battery will only last about

1000 ma-hr / 30 ma = 33 hr

And if the battery was replaced with a 30 volt 5 A-hr one? (5 A-hr = 5000 ma-hr)

The current would be

30 V / 100 Ohm = 0.3 A

and the battery would last

5 A-hr / 0.3 A = 16.7 hr

The power dissipated by the resistor would be

30 volts x 0.3 A = 9 W

which is far beyond the 1/4 W rating of the resistor and it would definitely burn up!

In this step, we started with Kirchhoff's Voltage Law (KVL) and then found out the details of the circuit by using Ohm's Law (E=IR) and Power (P=IE). Now that you know how to use these tools, it's time to apply them to a more use circuit in the following steps. Other tools will be added along the way.

## Step 3: Lighting the LED

In this step, we figure out how to light up an LED without burning it up!

By adding some more tools, the concept of a SERIES circuit and Kirchhoff's Current Law (KCL), we can determine what value the resistor should be.

Since each component is connected to only one other component on each side, this is considered a series circuit. Where each component is connected to another, I've placed a little dot. These dots represent Nodes which are where paths that the current can take are joined together. Following the red path of current (I) around the circuit, note that the current has only one entrance to a node and only one exit. KCL tells us that the amount of current entering a node has to equal the amount exiting. Looking at the red line path, we conclude that **the current (I) has to be the same through the entire circuit**, since what goes into a node comes out again. That is one very important piece of the puzzle to solve for the value of R.

The voltage X is still unknown and a side track to a bit about LEDs will determine X.

The LED (D1) has two parameters that are of interest. They are:

Max current: How much current it can conduct without damaging it.

Voltage Drop: The threshold voltage that must be met to cause the LED to conduct current.

These two parameter need to be known, or guessed at, before using a LED.

The LED used here is a typical T1 3/4 style RED LED.

Max current: 20ma

Voltage drop: 1.7v

NOTE: The direction of current flow through the LED is indicated by the arrow and bar. There will usually be a flat spot, on a round LED case, or colored dot, for other types, to indicate which lead is the bar (negative) side or cathode. The positive sided is the anode.

Now the analysis. Since the LED has a voltage drop of 1.7v and the cathode side is connected to 0 volts, the anode side must be at 1.7 volts. Therefore, X must be 1.7 volts.

Knowing X, the voltage drop across R1 must be

3 volts - 1.7 volts = 1.3 volts

And using Ohm's Law, the current through R1 must be

1.3 volts = I times R

Hmm..but what is I? This is where you get to make a design decision. The brightness of the LED is proportional to the current going through it.

This LED can handle a max current of 20ma, so this sets the upper value for I. From experience, this type of LED can been seen as ON when given about 2ma and most users set it up for 5 to 10 ma. So to let's use 10ma. That will make R1

1.3 volts / 10 ma = 1.3 V / 0.01 A = 130 ohms

but we're not done yet. Remember Power?

Assuming that the resistor is a 1/4 watt (0.250 W) resistor, can it be used?

Power = I x E = 10 ma x 1.3 volts = 13 mw = 0.013 W < 0.250 W

so the power dissipation is within the resistor's capability.

Using this type of analysis, it's easy to figure out why most projects use a 330 ohm resistor in series with an LED when connecting up to a 5 volts source like an Arduino board.

Given LED voltage drop = 1.7v, then R voltage drop must be 5v - 1.7v = 3.3v. So then 3.3 volts = I times 330 ohms leads to 3.3v / 330 ohms = 10ma.

If you don't want to use that much current from you battery to light up the LED, reduce the current by increasing the resistor value. Try working back through the math to change the current to 5ma or 3ma.

What value of resistor would you use for a 3.3 volt Raspberry Pi board?

Final note. Different LEDs can have different voltage drops, even if they are the same color. Values range from 1.6 volts to over 3 volts so be sure to check the specifications in the LED's datasheet. Also, some LED are more efficient than others in brightness. Have fun.

## Discussions