Practical Electronics For Makers (Part 1 of N)

Intro and Chapter 1 - In this book, we will learn basic electronics as we build our first circuit, learn what electronic components do and finally build our own devices.

Article Update Note

A reader mentioned a small issue with my explanation of calculating values in my circuit related to LEDs, forward voltage and Kirchhoff's Voltage Law. I built the circuit and hooked up a meter and saw that the current was lower than calculated when using only Ohm's law so I've made a change to this article to include that information.

Background

After completing my last book (Programming Windows 10 Desktop: UWP Focus (15 of 15)[^]), I wanted to jump right into the next one. I like to keep the fires burning and nothing stokes them for me like working with electronics. Since I started working with computers (in the Mesozoic Era) I've been interested in electronics in relation to what they actually do inside computing devices.

Obviously, electronics are an inherent part of all computing devices but as we focus on software many of us have never really considered what happens in the electronic components themselves. Now, with the explosion of inexpensive hardware which allows you to quite easily do embedded development many people are beginning to consider electronics a bit more. It's beginning to open up more I believe.

One of the problems I have found in the past is that there are few resources which just start at the beginning and go on from there (one of my favorite quote / paraphrases from Alice In Wonderland).

I'm so excited about writing this book that even though it's a bit rough (and I will most likely be slow in writing the book because it takes so much), I'd like to start posting chapters here. So, hopefully you'll find it interesting and helpful.

Introduction

I wrote the following introduction as a way to explain how this book works. When I started learning electronics I didn’t what to read about atoms and electrons. Atoms and electrons are interesting but what I really wanted was to start making things. I was happy to learn atomic theory later, but at the beginning it didn’t mean much to me.

Maybe you feel like I did. If you find yourself agreeing with the rest of this introduction then you will know the book will work for you.

Here’s what I wanted:

I Want To Start Making Things

There are things I want to make. I have a limited amount of electronics experience (or maybe none at all) but I believe the things I need to learn shouldn’t be too difficult. I know I am being a bit naive about this, but I want an author to guide me as I build projects that help me create something interesting.

I am interested in building something interesting and/or useful. I am not interested (yet) in all the electronics theory behind how things work. First I want to get some things working and doing stuff and then I can take the time to go back and understand it.

Build Circuits

I don’t mind if we start out simply turning an LED on and off. I just want to put a circuit together and start seeing something happen. Once the circuit works I will be far more interested in finding out why and how it works. I want to see a lot of circuits in the book and I want to see circuits as early in the book as possible.

Can’t We Just Assemble Components and Go?

Modern electronics are components so I’m guessing I should be able to learn some basics, put the things together and then learn how it all works. I don’t mind learning the theory as I build a project. As a matter of fact, I would prefer to build and learn in unison.

I also understand that some of the systems I want to build may be more complex than I can actually create at first, but I’d like to see some build-up to those systems. By build-up I mean a process something like the following:

Formulate an idea of something I want like ⇒ Open my garage door with my phone.

See the steps about how this might be broken down.

My phone has bluetooth, how do I send a message over bluetooth to my garage door to tell it to open? I think I’ll need to write an app for the phone.

My garage door does not have bluetooth so how could I add that? Is there a bluetooth component that is standalone? Is there a way to integrate the new bluetooth component with my old garage door?

My garage door does have a wall-mounted switch. If I could remotely activate that switch then the door would activate. How can I make that happen? Is there a component I could use to do this?

Read / watch a walk-thru of building the pieces of the system one at a time.

If It’s Too Difficult, The Author Should Provide It For Me

If something is too difficult or time-consuming at my present level of understanding then the author could provide that piece for me for download (if it’s software) or as an additional purchase of a prefabricated component. That way I can just keep on moving and building the project at hand if I want and then I can come back and learn exactly how it works when I’m ready.

Things Don’t Always Work The First Time

I know things don’t always work the first time and I’m fine with that. I’d like to see common problems that occur so that when I get stuck I understand that even the author gets stuck on things and gets discouraged. I’d also like to see common ways to test my circuits and determine why things aren’t working.

Motivation Is Rare, Remove Barriers to Entry

I have a lot of things to work on and I can’t always work on my electronics projects for long hours so make sure I have everything I need for a project ahead of time so I can jump in when I find a few minutes. Also, if I spend all my time finding components and getting my supplies together then I will be too tired to actually work on my project. Give me a list of everything I need (including tools I’ll use) at the beginning of each project so I can have everything ready.

I Don’t Want To Spend All My Time Searching For Components To Buy

Finding Components For Purchase From Reputable Sellers

I want all of the components I need to build a specific project right at the front of each project. I don’t want to search the Internet for everything so give me links to places I can buy the components so I can get them ordered and know I have everything as soon as they get to my mailbox. I don’t want to worry about whether or not I’m ordering from a reputable seller / website. Give me links to specific sites I should try that the author already knows are reputable.

Lead Me From Very Easy To Advanced Projects As Fast As Possible

Again, I don’t mind simple projects but lead me through them quickly and explain to me how this will be important later. As long as the circuits I’m learning are applicable then I don’t mind simple little circuits as examples, but always keep it in context of the bigger picture so I can keep thinking about how I can use what I learn directly in my own projects.

Workspace and Powering Circuits

I want the author to guide me in some basics which include getting my electronics workspace set up properly so I can jump into experiments when I’m ready. More than that, I know that powering my circuits can be a bit of a challenge at times because I need different voltages and current for various projects. I want the author to help me think through the best way to power my simple experiments and then best ways to power any of my projects that I hope to construct for long term use as finished products.

I Want The Book To Be Readable

I also want the book to be easy to read. I want the content to be able to stand on its own. I want the book to lead me through the material in such a way that I can first just read the chapter to learn and see the author run the experiment and see how things go. I’d like it to have pictures and good steps that show me how to recreate the experiment so that even if I am not able to do the experiment yet (because I don’t have the parts or equipment yet) I can still get a very good idea of how things will go.

An example of this in Chapter 1. I do some examination of components with a multimeter, but the reader may not have a meter yet or may be waiting to see if she is really committed before investing in a meter. I will attempt to describe everything we will do with the meter and then show snapshots of the meter in action. That way, it will be as if the reader is looking over my shoulder as we both run the experiment even though she doesn’t have a physical meter yet.

Cool Projects : By the Time I’m Done

By the time I finish the book, I want to have built a few interesting full-fledged projects that I can take further or which are analogous to the more advanced projects I’ve been dreaming of building.

Some of the things I want to see are:

Learn what all* the available electronic components are and the basics of what they do

Learn how to recognize components on a schematic diagram and read schematics so I can learn from other people’s circuits and capture my own circuits so I don’t forget them

Building projects with the least components possible in order to save money - ie Don’t use a microcontroller if I can do this with basic components

Do cool stuff with LEDs

Control circuits with IR sensor

Learn why switches & automating switches is the most important thing in electronics

Generate sounds and play through speakers

Using BlueTooth

Using LCD screens to display data

I had a nasty old time with a particular LCD screen and I’ll show you that. It was writing crazy data across the screen and I had to figure out why

Writing data to a SD card from my IoT project

Making things move with motors and servos

Writing basic code for Arduinos - the Arduino toolchain and what writing code for an embedded device really means

Make a music player with Arduino

Help me to learn how save power on my projects so they can run on the smallest batteries possible - I want to share my devices with people.

Allow me to open/close my garage door with my phone (via BlueTooth)

Learn how I can build a device to lock / unlock my computer with my phone

Only make me solder things when I must or when I’m doing a final project -- and provide some helpful basic tips on soldering

*Obviously there is a huge number of electronic components which would be to extensive of a list for this book, but we will look at a huge list of common components and how those components are used to make others. By the end of the book you’ll know how to read datasheets to get the info that you need when investigating new components that aren’t on my extensive list.

I Want It To Be A Collected Resource

I want the book to guide me through all of these projects and help me gain knowledge and it is fine that it isn’t necessarily totally new information which cannot be found anywhere else. I understand that instead it is a collected and targeted resource of some of the most interesting (author’s opinion) projects that the author has found. I want the author to tell me about those other resources also, so I can go further while I’m reading the book and once I’ve completed it.

That’s it. That’s the kind of book I’ve been looking for. That’s the kind of book I believe I have created (am creating) for you.

I created it for myself also, because this is a journal of the projects that I wanted. I hope you enjoy it as much as I have as I put it all together.

If this sounds like something you might be interested in, then let’s get started.

Here’s What You Will Learn

Components which have a positive side and a negative side are called polarized.

Not all components are polarized

A little about the three main players (voltage, current, resistance) of electricity. In other words, what makes up electricity as we know it and use it.

Reading datasheets

What is a datasheet?

Why would you read a datasheet?

What you can learn from reading a datasheet?

Basics of a multimeter (electronics measuring device)

Intro to Ohm’s Law

Here’s the battery you need:

You can see that this side (we’ll call the top) is labeled to provide some information.

This is a CR2032 and it is 3 volts (more about this in a moment). They will often shorten that to just a V like: 3V. These round little batteries are often called coin cells or button cells because they resemble a coin or a button. This one is about the size of a US nickel. These are also sometimes called watch batteries because a long time ago they were used predominantly in wrist watches.

Batteries (And Some Other Components) Have Positive and Negative Sides

The + label indicates that this is the positive side of the battery.

Batteries have a positive side and a negative side.

I mention this because LEDs (Light Emitting Diodes) are also polarized components and they too have a positive side and a negative side. Actually, since regular LEDs have two legs, they have one leg which is positive and another leg which is negative. There’s a picture of an LED (Light Emitting Diode) below.

The negative side of the battery looks like:

You can see that this side has a bit more texture to it. Probably just to make sure it doesn’t slide around inside whatever it is installed in.

Component Labeling

This side has little or no labeling. That’s how a lot of electronic components are: they provide info on one side or the other. This is a clue that if you don’t find any labeling then maybe you need to flip the component over or look elsewhere and you’ll probably find something.

Components May Be Polarized

As I said any electronic component may be a polarized component. That means that it has a positive side and and negative. This is important to know because you need to align like sides of different components when you build your circuit. However, not all components are polarized. We’ll learn about resistors which are not polarized (do not have negative and positive sides) and can be placed in a circuit in either direction. You can think of a regular piece of wire as non polarized also since a hook up wire can be placed in the circuit in either direction.

Electron Flow

Another way to think of polarity is that it is the way that electrons flow through a circuit. A polarized component is one that only allows electrons to flow in one direction through it. Components like, a section of wire, which allow electrons to flow either way are not polarized.

The LED only allows electrons to move in one direction so it is polarized.

Even in this first simple experiment we need to understand polarization since we will need to connect the positive side of the LED (Light Emitting Diode) to the positive side of the battery and the negative sides to each other.

What Does Positive / Negative Really Mean?

You may be wondering what it really means for something to be positive or negative. This is usually in reference to the power supply. In our case, the power supply is the battery. The battery has one side which has an excess build-up of electrons. Since electrons carry a negative charge the side of the battery with the excess electrons is considered the negative side in comparison to the electron deficient side - the positive side of the battery. It is this difference which creates a voltage. We’ll talk more about this in a moment. For now, simply understanding that the negative side is the side with the excess electrons is enough to understand other concepts.

Aligning Like Sides of Polarized Components

To get the LED to work, we will need to align the positive leg of the LED with the positive side of battery and the negative leg with the negative side of the battery.

First Experiment

Let’s try our first experiment which will make the LED light up. It’s very simple. You do not need anything except your LED and the coin cell battery we mentioned.

LED : Longer Leg Is Positive

If you’ll take a close look at the LED you are going to use you should see that one of its legs is longer than the other. That one is the positive leg. That leg will need to touch the positive side of the battery.

Obviously, the shorter leg will be the negative leg and must touch the -- you guessed it -- negative side of the battery.

You can do this now by holding the battery vertically in one hand and lowering the legs until one touches each side of the battery.

Here is my CR2032 battery sitting on a breadboard, leaning up against two wires (to stabilize it for pictures).

Here I am holding the legs of the LED to the appropriate sides of the battery so that the LED lights up. Please keep in mind that the wires behind the battery are doing nothing more than stabilizing the battery so I can use a hand to take the picture.

If for some reason you cannot tell which leg of the LED is longer there are (at least) two other things you can check to determine which side is which.

Flat Side of Plastic : Negative

If you look very closely at the plastic covering of the LED you will see that one side (thinking of sides as where each leg enters the plastic) is flat on one side. That side is the negative side and of course process of elimination tells you the other side is the positive side.

You can also look inside the plastic so you see something like the following:

You will see that one side is larger than the other. In the image you can see the metal plate on the right side (inside the plastic) is much larger. The larger side is the negative side and of course, the smaller side is the positive. The larger side is called the anvil and the smaller side is called the post.

You can see that the negative side of the LED is also called the cathode and the positive side is called the anode. We’ll talk about that more as we go and we see those terms associated with other components.

What If You Touch Both Legs To Positive Side?

Maybe you’re wondering what happens if you touch both legs to the positive or both legs to the negative side of the battery? Will the LED break or explode or melt? No, nothing will happen at all. Go ahead and try it so you can see for yourself.

Why Doesn’t Anything Happen?

Nothing happens because no electrons are flowing. Why don’t any electrons flow? Because there is no voltage difference between the two legs of the LED. What does that mean?

Voltage is the part of electricity that pushes electrons through a circuit. Voltage is the pushing power of electrons. If there is no voltage difference between two points (in this case between the two legs of the LED) then no electrons will move. There are electrons in the circuit but there is no pushing power when you connect both ends to the same polarity (both + (positive) or both - (negative). The pushing power (voltage) of a circuit is created by a difference between the electrons at two points in the circuit. If you have no difference between the two points (in this case the two legs of the LED) then you have no voltage and no electron movement and no electricity flow also known as current.

Voltage Can Be Thought of Like Water Pressure

Imagine a pipe filled with water but laying on a level surface - both ends of the pipe are level. Since there is no difference between the two ends of the pipe the water does not flow. However, if you lift one end of the pipe the water will begin to flow toward and out the low side of the pipe. That is a good analogy to how electrons behave.

You can also think about this as water in a stream. If the stream bed is completely level then the water would not move. If the water does not move we say there is no current. We call moving electrons current also. So, if there is no voltage there is no current -- no moving electrons. If there are no moving electrons then we don’t get any electricity -- there is no current.

There is potential energy (energy at rest) there, but since the current is not moving nothing happens. To get something to happen the electrons have to get excited. For example, any copper wire contains electrons but until the copper wire is connected to a source that contains an excess of electrons at one end and a lack of electrons at the other end (usually thought of as ground) there is no voltage and no current flows. Voltage, the pressure to push electrons through the wire, gets electrons to move. But to get voltage there must be a pressure differential between the parts of the circuit. In the case when you connected both legs to positive or both legs to negative there was no pressure differential so nothing happens. It was as if the pipe was laying on level ground.

Electrons Move, LED Lights Up

However, when we connect the positive leg to positive and negative leg to the negative side then (with a properly charged battery) electrons begin to flow. When the electrons flow they travel through the wire bond of the LED (shown in previous image) to the semiconductor die. When the semiconductor die is activated it releases energy as photons (light) which lights up the LED.

The pressure difference that we are talking about is because the battery we are using has a build-up of electrons on the negative side of the battery compared to the positive side. Since there is a build-up of electrons on the negative side, it creates a pressure difference and a voltage between the negative side and the positive side of the battery. When that happens and you connect to each side with a conductor (a wire, metal, LED, etc) which gives up its electrons, then electrons can flow from the negative side to the positive side.

How Batteries Die

As you use a battery, the positive side continues to gain electrons. When it finally gains as many electrons as the negative side has (after long use of the battery) the battery will no longer work since the voltage difference drops to zero. This is when we consider a battery to be dead. It has achieved a state of equilibrium of electrons between the two points. It’s as if both ends of the pipe are at the same level again.

A Quick Word About Moving Electrons

In the previous paragraphs and as we continue through the material you will see that I mention that electrons will move. For the atomic theory purists out there I have to take a moment to mention that the electrons don’t move through the wire like a car traveling on a highway. This is really just a convention that we use to help our understanding. A better way to explain how the electrons move is to think about a tube full of ping pong balls. When you push one ping pong ball in one end of the tube, then each ping pong ball moves only slightly and the ping pong ball at the far end falls out. That’s probably a better representation of how the electrons in a conductive material move from one atom to the next, but as we talk about current and as you read in other places most people discuss the movement in a conventional way of thinking about the electrons moving like a car down a highway and that is fine for our purposes.

How Much Voltage?

Different amounts of voltage are required for different types of work to be done. Obviously if we need to push more electrons faster we are going to need more voltage. In the case of our LED if we don’t supply enough voltage then the electrons will not have enough energy to move and the LED will not light up.

How can we know how much voltage we need for a particular thing we are trying to do?

The original manufacturer of a part will supply this information so we can check it and know. This is all part of becoming familiar with doing electronics work.

How Many Volts to Drive an LED?

You can just Google something like “how many volts to drive an LED” and you’ll probably get a good answer back.

My battery is currently supplying 3.077V and 40 mA of current.

Here’s how I measured the voltage of my battery.

I started up my multimeter (multi use meter) which can be used for measuring voltage and current and other measurements.

I set up my meter to measure voltage by connecting the probes to the correct ports on the multimeter. I then touched the negative probe (black) to the negative side of the battery and the positive probe (red) to the positive side of the battery and looked at the multimeter screen where it displayed the voltage (3.077).

Measuring voltage and current has to be done in different ways. You must measure voltage drop across a component from one side to the other side (from the high side to the low side) because it is measuring the difference between the two sides. Just as you cannot get the LED to light by touching both legs to the positive side of the battery, you cannot measure voltage by touching both probes to one side of the battery. Instead to measure voltage we have to measure the difference between two points, so the probes have to touch two different points -- not the same point (negative or positive side).

Here’s a schematic showing a voltage meter as we are using it to measure our battery.

I know that seems extremely simplistic, but it’s good just to know that even a meter can be represented in a schematic and it actually shows us that the probes of the meter need to be placed properly. In the case of a voltage meter, the probes of the meter must be placed across a place where there is a voltage difference in order to measure voltage otherwise there is no voltage to measure. We’ll talk more about that as we go along.

Here’s another view of the meter without two probes touching. The value on the screen just rolls around to different values so you’ll have to ignore the value shown since it isn’t actually measuring anything and is meaningless. The image shows the voltage at 13 mV but it is just a randomly generated value since it isn’t really measuring a voltage difference in any way.

The main thing to keep in mind here is that the red wire you see is all one probe (the one end plugged into the meter and the probing end pointing at the battery. The same is true for the black probe. The point is that there are just two wires (two probes) and with those two probes you can measure voltage.

We will use these same two probes to measure current also, but the red probe will be moved over to the other port on the meter. But the common probe (black one) will stay in the same port.

Measuring Current

We can also measure current but it has to be done in series with the circuit. In series with the circuit means the multimeter becomes a part of the circuit. To understand this better we need to think about what a circuit is and how electrons only flow through a continuously connected circuit.

This idea is sometimes confusing so don’t worry if you don’t exactly understand it yet. It will become more solidified as we move through the book. I just want you to know that you have to measure voltage and current differently and that we can measure both using a meter.

That datasheet lists absolute maximums for the particular LED SparkFun sells and they look like the following:

Notice that it states the max forward current should not exceed 30 mA. However, the current from my CR2032 coin cell is actually providing 40 mA. There is a good chance that this will limit the lifetime of the LED. But it works for our purposes.

Another section of the datasheet also shows max voltage:

Effects of Exceeding Max Voltage

As you can see the maximum voltage is 2.2V Since we are using a 3V battery we are driving electrons too quickly through the LED. This will generate more heat and will make the components (post, anvil, plastic covering) break down much more quickly since materials are not rated at this level.

Of course, since we are only using it for short bursts by touching the two legs to the coin cell periodically we probably won’t damage the LED enough for it to matter. But if this were wired up in a circuit the LED would have a noticeably shorter life span.

How Current Is Measured

Current is measured by the number of electrons that pass a point in a specific amount of time. While Voltage is measured in Volts. Current is measured in amperes which is usually abbreviated to amps. One amp of current is one coulomb of electrons (6.24 x 1018 or 6.24 quintillion electrons) passing by a point in the circuit in one second. That’s a lot of electrons.

In our little circuit we are not at one amp but only 40 mA (milliamps) which is 0.040 amps. Since milli means thousandth this is forty-thousandths of an amp. So we aren’t pushing as many electrons past the point as quickly. However, we are pushing more than the max 30 mA that the datasheet tells us this LED can handle. Since electrons create friction in the circuit they create heat too and that heat is bad for our circuit since it is more than is easily dissipated quickly.

Here’s how I measured the current in this little circuit using the multimeter.

Here’s the schematic of the Ammeter in our circuit.

This actually shows us that our ammeter is a part of the circuit. In other words, it is added to the circuit just as we add any other item in our circuit -- such as an LED or a resistor or any other component. Again, you’ll see more about how this is different than the way we have to measure voltage as we continue through the book.

Quick Example of Measuring Voltage Differential

But, here’s a quick example of how measuring voltage is different. Voltage has to be measured as the difference between two points. In our original schematic with our Voltage meter we were only measuring from the positive side of the battery to the negative side so it was obvious that we had a voltage differential. However, when there is a component in the circuit it is a bit different.

If you look back at our original schematic measuring voltage (shown below at the left) and compare it to an example on the right (which contains an additional LED component) you may think the one on the right is fine for measuring voltage. However it is not.

If you look closely at the one on the right, both probes are one the negative side of the circuit now and there is no voltage difference. When there is one or more components separating our circuit then we need to make sure we measure voltage across the component(s).

I know this may still be a bit confusing, but here is how you would measure the voltage across the LED component.

Now, the positive probe is on the positive side of the circuit and the negative probe is on the negative side and now a voltage will show up on the voltage meter. Notice also that this is different than the way the ammeter (measuring current is done).

This May Still Be Confusing.

The point of all this explanation and example is simply to introduce you to these concepts so you can think about them as you learn more. If it still seems confusing, it is okay since we will see this going forward. Of course, we will build circuits in the upcoming chapters and measure them with our voltage and ammeters (multimeter) and we will see this work in real life instead of just as a set of images.

Much Heat Is Generated

If we pumped up the voltage and created more current in this circuit it would get to the point where the LED would melt. That’s because electrons create friction inside the circuit and that friction creates heat. Eventually, the legs could become so hot that they would burn you if you were holding them. Excessive heat is one of the dangers when working with circuits so be very careful. Always check your components and your power sources so you properly consider max voltage and current.

You are also beginning to see that Voltage and current are closely related to each other because as we raise voltage, current in a circuit is generally increased. This is similar to thinking about the water in the pipe. If you only raise the pipe a few degrees the water will not move as fast (water current will be slower) than if you raise the pipe 45 degrees. With all other things in the circuit being equal, voltage and current are directly proportional to each other. As you raise voltage so too current rises.

How Might We Control Voltage?

At times we may have a battery that has a voltage that isn’t quite right. In our simple circuit we really have a battery source that is too high at 3V and it is causing us to go over our max current rating for our LED. However, it is difficult (if not downright impossible) to create a battery that is exactly the voltage that we need for each of our circuits. However, just as you can create smaller pipes that limit the maximum amount of water which can flow through them, we can use a component to limit the speed of electrons (current) which move through the circuit.

The main component we use to do this is called a resistor since it resists current flow. It actually resists current flow by dropping the voltage in the circuit.

Yes, A Little Math Helps

Since voltage and current are related there is a very small formula we can learn which allows us to calculate how much voltage we should be using to get a specific current value to flow in the circuit. Please don’t be bothered by the math. It is no more difficult than figuring out how much money you have left over when you buy an apple pie at McDonald’s with a $5 bill.

My point is that you do those kinds of calculations all the time and you don’t break out in a sweat and fear math.

For now, you don’t even have to understand it. Just plug in the numbers and get the answer you need.

Ohm’s Law

Ohm’s law states that voltage (measured in volts) is equal to the current in a circuit (measured in amps) times the resistance (measured in Ohms) in the circuit.

It’s much simpler to see this as a formula.

Voltage = Current * Resistance

Of course, people shorten things so you could see this as:

V= C*R

However, there is some history behind this and originally Voltage was called Electromotive Force. That makes sense because we know Voltage is the pressure or the force that pushes the current through the circuit.

That’s why you’ll see Ohm’s law stated as:

E = C*R

That still means Voltage = Current * Resistance.

However, you won’t actually see it that way because current was named by French researchers as intensité de courant (intensity of current). So an I has historically been used for current in a circuit. So replace the C for current with an I and you’ll have:

E = I*R

And since mathematicians really like abbreviations you’ll generally see it as :

E=IR

No More Changes

That’s it. I promise I won’t change it any more.

Sometimes we know the Voltage and we know the current we want, but we don’t know the resistance that we should use (via a resistor component) to get the current that we want.

That is the case in our first circuit.

We know we have 3V and we know we want no more than 30 milliAmps but we don’t know what resistance to use. To calculate that, we just rearrange our original formula so we can solve for R(esistance).

Here’s what it looks like:

E/I = R

Of course that simply means Voltage divided by Current will give us the size of the Resistor (in Ohms) that we need.

In our case we plug in the numbers and go:

3 / .030 = R
3 / .030 = 100 Ohms

That worked out very well. So, if we wanted to protect our circuit for long term use we would just add in a 100 Ohm resistor and then the current would be limited to the 30 milliAmp max.

But, alas, the real world is not exact and neither are resistors. They are only good within certain tolerances. Of course, the 3V battery isn’t exact either since I measured it at 2.92V at one time and 3.077 at another time.

If we plug in that real Voltage we get:

2.92 / .030 = R
2.92 / .030 = 97.333 (repeating decimal)

The nice thing about electronics is that it is not exact. Generally you can be a bit off. But, of course, since the max current is 30 milliAmps (mA) on the LED we want to make sure we are a bit below that value so if there is a surge or if the battery is 3.1V we will be okay.

We can do that by simply increasing the resistor a bit.

Instead of just guessing we can pick a current value we like that is a bit below the 30mA max and then do our calculation again.

Of course if we choose a current that is too low then the LED will not burn as bright or if we limit it too much then the LED will not light up at all. Back to the datasheet.

I see a row that looks like:

Suggestion* is most likely supposed to be Suggested. So, the datasheet is saying this LED works well with 16 - 18 mA of current. That’s great. See how helpful these datasheets can be?

Let’s go with the max best of .018 A.

3 / .018 = R
3 / .018 = 166.666 (repeating decimal)

Resistors Don’t Come In That Specific Size

When you go shopping for resistors you will find that you don’t find them in that kind of precise size. That’s okay though, because we can find something close.

In this case we’ll just go up a bit higher to a 180 Ohm resistor.

Let’s recalculate using the 180 so we can see what our final current value will be.

Since we are not calculating for final current we want our formula to look like the following:

E / R = I
3 / 180 = .01666 (repeating decimal)

16mA is a good number for us. However, we're missing some information that we need to get our calculations correct.

We Need A Bit of Additional Information

All of this that we've calculated so far would be exactly correct, if our circuit were made up of just the battery, the wires and the one resistor. However, we have forgotten to consider that we also have an LED in the circuit and the LED also creates resistance in our circuit. That means the actual current flowing in the circuit will be lower than 18mA that we previously calculated.

Let's take a look at the first simple circuit we are going to build in Chapter 2 so you can get an idea of what the components look like:

Forward Voltage (Vf) of LED

The challenge here is that we don't have the resistance value for an LED, instead we have the Vf (forward voltage) drop that will occur over the resistor. As stated in the data sheet, the voltage drop will be somewhere between 1.8-2.2V. Usually we just use a value somewhere in the middle like 1.9V to do our calculations.

To calculate our required resistor size, we just need to keep the Vf (forward voltage) of the LED in mind and slightly change our previous formula.

Since the LED will actually drop our battery voltage down by 1.9V we change our previous formula to look like the following:

Battery voltage (3) - LED Voltage drop Vf (1.9) / R (180) = I

Subtract the forward voltage drop of the LED (1.9V) from the total battery voltage (3V).

3 - 1.9 = 1.1V
1.1V / 180(Ohm) = .006 = 6mA

Again the simplified formula might look like the following (I'm using Vb to be Voltage of battery):

(Vb - Vf) / R = I
(3V-1.9V) / 180 = .006

Less Current Could Affect the Circuit

6mA is a much lower value for the total current flowing in the circuit that what we had previously calculated (16mA). This is important to know since lowering the current could even cause the LED to not light up.

Now that we've effectively changed the total voltage (because of the LED Vf drop) we should calculate our target resistor again.

1.1V / .018 = R (target resistor size)
1.1V / .018 = 61.111

Of course, as I said before you aren't going to find resistors for every calculated value so we'll just use a 100 Ohm resistor in this case. Again, let's recalculate so we know what our target current will be.

1.1V / 100 = I (target current)
1.1 / 100 = .011 (11mA)

That's A Lot of Information

We will continue to go over this concept in the future, but I wanted you to know about it now since it does affect the current and will help your learning as we continue through the material.

Summarizing the Formulas

Let’s summarize the formulas for Ohm’s law and this new information I've just given you so you don’t feel overwhelmed by any algebra.

Calculate Any Value From Any Other Two

We can calculate any one of the three values (Voltage, resistance or current) simply by choosing the formula below and plugging in the two known numbers we have.

Calculate Voltage

E = IR (easy multiplication)

Calculate Resistance

R = E/I

Calculate current

I = E/R

Always Consider Forward Voltage With LEDs

Of course, if you are adding an LED into the circuit you have to first calculate your total voltage by subtracting your Vf drop over each LED in the series circuit. Calculating the total voltage is easy, of course. Just subtract your Vf drop from your battery voltage.

(Vb - Vf) = total voltage = E

We'll talk more about this and the fact that this is actually a part of Kirchhoff's Voltage Law later. Also, in chapter 3, we will set up a similar circuit and measure it with the multimeter so you can see first-hand that the current is lower because of the LED voltage drop.

Do Not Worry About Formulas Too Much

Don’t be too worried about those formulas because they will become second nature over time. If they still confuse you at this point it is not a problem, we’ll keep working them together and by the time you are halfway through this book you’ll have them all memorized and they will make sense to you.

We've Learned A Lot In This Chapter

You’ve learned a lot in this chapter and you got to see how the knowledge you’ve gained actually applies to real circuits. I know there was only one circuit in this chapter but the things you’ve learned with that circuit (polarity, voltage, current, resistance) will make the next chapter where we build many circuits much easier to understand.

This chapter didn’t include a very nice example of a circuit because it wasn’t a circuit that could stand on its own. You had to hold it together in your hands. From now on, starting in Chapter 2 all of our circuits will be built to stand alone. To do that we will use breadboards.

Upcoming Chapter

What Is a Breadboard?

To prototype circuits a thing called a breadboard is used to hold your wires and components together so you don’t have to solder things together just to test. Breadboards are plastic blocks which provide underlying electrical (metal) connections which hold your components together as if they are built as a printed circuit board. We’ll look at them much closer in chapter two. You’ll need breadboards and all the other components listed at the beginning of the chapter so go check out the list and get the parts ordered so you have them when you are ready.

Everything Important Is A Switch

In the next chapter we are going to look at :

The unexpected importance of switches -- I’m hoping this talk will excite and amaze you as you discover a new way to think about automation and switches.

The vast number of things in electronics which actually play the role of switches. With a switch being such a simple concept it is amazing (and awakening) that switches are realized in so many ways in electronics.

Draw a circle with a horizontal line through its middle, and a vertical line from the circle's center down to the bottom circumference. Put the letter 'E' in the top half of the chart, and an 'I' in one half of the bottom half of the chart, then an 'R' in the other. Then you have something like the following:

If anyone is interested in doing the practical work on a simulator, you can download (for free), a circuit editor, simulator and libraries of components from www.designsim.com.au/dssdnld.html.
There's also other stuff, like a signal generator, spectrum analyser, oscilloscope and a set of DSP functions.
It only runs on Sun or Linux, but it is free, so enjoy.

Most of the maker articles I see are based on code and micro controllers. It is very important to get the basics down before you hook up anything to a micro controller. Even at their current low cost the iterations of ordering a new controller because a port failed under overload will quickly get discouraging.

Your article reminds me of the articles I read in Popular Electronics and various books written by Forest Mimms that got me interested in electronics over 30 years ago. That interest grew into a career in electronics design and programming that I have practiced since.

I also like your bare-metal goals. A quote attributed to Albert Einstein "Make things as simple as possible, but no simpler." is excellent guidance.

I intend to continue following your series and maybe get back into something that calls for a little Ohms Law.

Thanks very much for reading my article and commenting.
I appreciate all readers / commenters but it is always especially inspiring when it is someone who is working in the industry and has a lot of experience but still enjoyed my article.

It looks good but it isn't helpful that it shows up in the C++ section and displaces other articles off the end of the list. It just isn't anything to do with C++. No downvote for this though. It is just an administrative issue.

That is very odd, because I did put it under Arduino section and chose some keywords like electronics.
If I edit the article I'll check and see if there is anything odd but of course the CP editors control most of that.
Thanks

I took some electrical engineering classes way back in the late 70's to early 80's. I have regretted not keeping my books from those classes and forgotten most of what I learned. I have been really enjoying what you have so far and ordered a breadboard kit so I can do the projects as I read the next chapters.

Thanks, very much, for reading and commenting.
I'm very excited to hear you enjoyed this part and that it has helped to get you started in electronics again. Very cool.
The 2nd chapter is out (Practical Electronics For Makers (Part 2 of N)[^]).
Hopefully it will be helpful to you also.

First off, I love the article format and presentation - great work there!

But all of the resistor calculations are dead wrong. The job of the resistor in the circuit is to allow enough current to light the LED, but not so much that the LED overheats and fails. With a 3.1 volt battery (assumed worst case) and a forward voltage across the LED of 1.8 - 2.2 volts, the resistor must drop 3.1 - 2 volts (an average value) at a current of 18 mA. A drop of 1.1 volts at a current of 18 mA requires a resistance of 61.1 ohms. Since this is a non-standard resistor value, I'd select a 56 ohm resistor. This selection will allow a bit more current to flow, about 20 mA, but it will ensure adequate current to light the LED, without exceeding the maximum forward current rating.

The key point to take from this is that, as one walks around a circuit, the sum of voltage increases (the battery) will always equal the sum of voltage drops (the resistor and LED). This is known as Kirchhoff's Voltage law (http://www.electronics-tutorials.ws/dccircuits/kirchhoffs-voltage-law.html[^]. A complementary rule states that, at any given point in a circuit (called a 'Node'), the sum of the currents entering the node must equal the sum of the currents exiting the node. These are two extremely valuable rules to help you on your journey of discovery.

You're off to a great start, and I like what you've done so far, but please get the basic principles right before you get yourself, and possibly others, between a rock and a hard spot. Feel free to email me any time you run into an electronics issue you can't solve, or are just unsure about. I'm a retired electronics engineer who programs stuff as a hobby; you're a programmer who wants to learn about electronics. We probably can learn a bit from each other.

Thanks for reading my article and commenting. I can tell you are an informed reader and I feel that your concern is real and not just trying to create controversy.

I'm reading and processing your comments and I believe we are actually in agreement.

Different Perspectives
I believe the challenge that we are having is that we are both coming from different perspectives.

Everything At Once
You obviously have extensive experience with electronics and all of that knowledge is coming to play in your perspective and reaction to my article.

My Challenge As An Author
The challenge I have as an author is to somehow present information to the new(er)(est) readers so that they can begin at a point and build upon that knowledge.

Not Just Theory or Information Dump
Along with that challenge comes the challenge of not dumping every electronics theory upon the reader before they ever touch a circuit. I chose to start with Ohms law because it provides the basics of calculating the three main values (Voltage, Current, Resistance) that are present in any electronic circuit. Keep in mind that I' writing to readers who previously (most likely) didn't even know the 3 variables of electricity.

As an author I had to choose a communication angle to use to lightly introduce the Voltage, Current, Resistance to the beginning reader which would allow them to build a very simple circuit.

Seriously Flawed
The one problem I have with what you said is that you said it was "seriously flawed" and "resistor "calculations are dead wrong".

However, using basic Ohms law to reverse calculate the resistor size isn't entirely wrong, I don't believe. Yes, there is more information to understand the circuit completely and I have learned Kirchoff's Voltage law in the past and I know that understanding it will make the calculations correct.

However, the language you used could make a beginner think that the circuit we created (with higher resistance value) is dangerous, which I do not believe it is. If anything my circuit example would be more likely to fail because it resists more current -- larger resistance is calculated.

I Believe Your Concern Is In Good Faith
However, I also know you are attempting to register your concern that what I've said is not strictly and exactly correct and I believe you are doing that in good faith to help me and readers. I also recognize that you did not just flame me but you said you'd be happy to help and that means a lot.

Possible Solution
I believe a possible solution to the entire matter -- considering that this is the first chapter of the book -- is to :

Make a note that Ohms law does not allow us to calculate proper forward voltages over components entirely properly, but for this first circuit we can get basic values which are close enough. As we move forward in the text we will see how understanding Kirchoff's Voltage Law will be more helpful (and correct) in making these calculations.

Does This Make Sense?
I'm really hoping what I've said makes sense and seems reasonable and I am hopeful you'll reply so I can create the best solution possible.

You are correct that I am interested in improving your excellent work, not simply detracting from your article; you're off to a great start, and I hope to see this work completed!

By "seriously flawed" I don't mean to imply that you've incorrectly used Ohm's Law; you simply applied it to the wrong part of the circuit. You cannot neglected the voltage drops of other components in a loop and get a correct result, and you don't have to have any special knowledge of LEDs to compensate. You have the spec sheet in the article (nice touch, by the way) so it's a simple matter of reading the given values and adjusting the total voltage drop required of the resistor to make your calculations correct. This is not a minor matter; it's crucial.

I'm here to help, because I think that programmers are often lacking in understanding the hardware they're attempting to control, and a solid understand of circuit principles will make them better programmers. I'm in favor of that, and happy to assist you in crafting a truly superior tutorial. Feel free to email or PM me if you bump into any more bits that you're unsure about, and I will be happy to respond.

Thanks so much for all of your encouragement. I really appreciate it and I appreciate you explaining this issue with my article.

You Are 100% Correct
Since I work a day job, it has taken me a bit to investigate this further, but I have done so and building the circuit and measuring the values has proven you exactly correct:
My calculations are seriously flawed.

Built Circuit / Measured Values With Meter
After building the circuit and powering it with my two NiMH batteries in series (2.6V total) I discovered that my total current was only around 3mA, while my Ohm's law calculations gave me around 12mA.

Your Comment Helped So Much
Of course, all because you commented, I suspected that this was the missing calc of Vf that was causing this. If you hadn't commented I'm not sure what I would've thought because even with your comment I was dismayed as I read the values showing on my meter.

As I suspected (because of your input) it was all because of my improperly calculated values which you mentioned.

Now, what I want to do is alter the article explaining why we cannot only use Ohm's law but must apply additional understanding to calculate the values properly.

I actually like to detail these kinds of challenges for my readers also because it is the kind of thing that is not intuitive / well documented that beginners get stuck on and don't know what is going on.
So hopefully, this will end up making the article better.

Hi,IT is Nice work and I look forward for the next chaptet
... About the resistor calcolation ,I recomand the folowing concept:ușe the forward voltage on led substracted from main voltage and then divide IT by rated curent to obtain the resistor value ,IT is more exactly and safe .Thanks

Yes you need to subtract the forward voltage for the LED to get the correct resistor.
So Led Resistor = (Battery Voltage - Led Forward Voltage) / Led required Current
I say required current as you may want this to be less than the maximum current on the data sheet. A lower current draw will extend the battery life.

keep going with the article

Why is it when you are busy everyone whats it yesterday, But when your not no-one has any work for you?