(561) 600-0707 contact@takeupcode.com
Select Page

Knowing some basic electronics helps you become a better programmer.

You might have seen warning signs that say “Danger: High Voltage” But do you know what voltage really is? You’ve probably used batteries until they’re dead. But do you know what that means? I’ve talked about high voltages representing binary ones and low voltages representing binary zeros. What are these voltages? Is high voltage in a computer the same as high voltage at a construction site?

The way I first learned to think about voltage was using water and pipes as an example. You might think that water is voltage but that’s not quite right. Water will flow from a high place to a low place because of gravity and if you restrict this flow by making it go through pipes, then it’ll build up pressure. This is why towns build water towers to raise water high in the air. It provides a reservoir of water with a natural tendency to create pressure.

The water itself in this example relates to charge. The pressure is voltage. The flow of the water is current. And the pipes not only resemble wires but also act as a source of resistance. Let me explain each of these a little more.

Listen to the full episode for a more detailed explanation of charge, voltage, current, resistance, as well as Ohm’s Law and how they relate to each other. You can also read the full transcript below.

## Transcript

You might be wondering why I would talk about electronics. This is a podcast about programming and I mean to keep that focus. However some understanding of electronics can actually help you become a better programmer. Especially if you’re programming robots, or 3D printers, or whatever invention you’re working on. Programming is becoming more and more important. And the best programmers will be the ones who can apply their skills beyond the computer and smart phone.

I studied electrical engineering in college not only because it was fun and interesting but because I knew that it would allow the most flexibility with my career. I knew that I could continue with electronics or become a programmer. Going the other way is much harder. But exploring just a little electronics is not that difficult. I’ll stick to the basic concepts that I think will help you the most.

You might have seen warning signs that say “Danger: High Voltage” But do you know what voltage really is? You’ve probably used batteries until they’re dead. But do you know what that means? I’ve talked about high voltages representing binary ones and low voltages representing binary zeros. What are these voltages? Is high voltage in a computer the same as high voltage at a construction site?

The way I first learned to think about voltage was using water and pipes as an example. You might think that water is voltage but that’s not quite right. Water will flow from a high place to a low place because of gravity and if you restrict this flow by making it go through pipes, then it’ll build up pressure. This is why towns build water towers to raise water high in the air. It provides a reservoir of water with a natural tendency to create pressure.

The water itself in this example relates to charge. The pressure is voltage. The flow of the water is current. And the pipes not only resemble wires but also act as a source of resistance. Let me explain each of these a little more.

Let’s start with charge? Atoms have electrons with negative charge orbiting a nucleus of protons with positive change and neutrons with neutral charge. Atoms have the same number of electrons as protons which cancels the charge and the atom as a whole has no charge. But if you take away some electrons or add some extra electrons, then the atom becomes an ion. Charge is measured in coulombs and it takes 6.242 x 10 to the 18th power number of electrons to get 1 coulomb of negative charge. You can also have the same number of protons to get 1 coulomb of positive charge. If you want to write this number on paper to see how big it is, start by writing 6.242 and then move the decimal place to the right 18 times. You’ll have to start adding zeros once you get past the 2 4 2 part.

It’s hard to relate to such a big number though and I found some interesting facts on Wikipedia that might help. They say that a typical lightning strike causes 15 coulombs of charge to flow and this can go as high as 350 coulombs sometimes. But the really interesting part is that a typical AA alkaline battery can cause up to 5000 coulombs of charge to flow over its lifetime. At first, this seems impossible. Lightning can kill, it can cause trees to explode, and it generates thunder as sound waves that can travel for miles and flashes of light that can light up the entire night sky. How can a simple AA battery generate over 300 times as much charge? The difference is time. Lightning surges all its charge almost instantly. While a battery slowly drains over weeks. A battery generates charge through chemical reactions and the simple AA battery just can’t keep up with the same rate of flow that lightning can produce. When a battery has no more chemical reactions inside that can generate charge, it’s dead.

You’re familiar with charging your phone or other devices but what does that mean? Well, some batteries have a chemical process that can be reversed. When used to drive an electronic device, the chemical process produces extra electrons on the negative terminal. And when you charge the battery, it’s like pushing these electrons back inside the battery. What’s actually happening is the chemical reactions are being undone so they’ll be ready again when needed.

Next up is voltage. Water under pressure will try to escape. If it can’t escape, you can keep squeezing it to even higher pressure. The container holding the water resists the water from leaving. Eventually, if you increase the pressure too much, the water will break out anyway. The same thing happens with electrons if they’re gathered together in one place and a path appears for them to exit, then they’ll begin following that path. Just like how water under pressure will begin flowing the moment you open a tap. The higher the pressure or the more electrons, the faster the flow.

This pressure of charge is measured in volts. One thing I want to make clear is that you measure voltage by looking at the difference in pressure between two points. You might think that there’s a lot of electrons crammed into a space but if there’s the same number in another place, then the voltage is zero between these two points. Voltage is often called a potential difference because it looks at what could happen if there was a pathway between any two points. Voltage can also be positive or negative just by changing the order that you use to examine the difference between the two points. All this means is that you can’t just point to a single spot in an electric circuit and say there are 5 volts. It’s always in relation to some other spot.

Usually an electric circuit will have something called ground. It gets this name because you can think of that point and any other point in the circuit called ground as if it really was connected to the actual dirt outside in the ground. Sometimes it really will be connected to ground and sometimes it’ll just be a common place that you can assume all voltages are being compared with. With this understanding, if a single point is said to be at 5 volts, then that means there’s a 5 volt difference between that point and ground.

I mentioned circuits just now. Let me take a quick detour to explain. A circuit is just a complete path that allows charge to flow. If you have a battery and connect one end to a terminal on a light bulb, the light will remain unlit because there’s no complete path yet. Once you connect the other terminal on the light bulb to the other end of the battery, you’ll complete the circuit and charge will flow. The light should also turn on.

In electronics, you’ll mostly be working with voltages of either 5 volts or 3.3 volts. Either of these is considered to be a high voltage representing binary 1. And zero volts represents binary 0. The type of voltage in your house is a bit different and I’ll explain that next week but it’s either 120 volts or 240 volts. The type of voltage that causes warning signs will usually be in the thousands of volts. And lightning can reach into into hundreds of millions of volts.

Once you have charge flowing, you have current, which is also sometimes just called electricity. Current is measured in amps. The more charge flows, the more amps you’ll have. And also, the faster the charge flows, the more amps you’ll have. One amp is defined as 1 coulomb flowing in 1 second. In electronic circuits, you’ll mostly be working with milliamps or microamps. Those are thousandths and millionths of an amp. But you can also easily get into several amps when driving motors or powering electronic devices.

The last topic for today is resistance. Everything has resistance unless you’re working with superconductors. A conductor is anything that can transport charge from one point to another. Usually, this is metal such as copper just because it has a low resistance. But even copper will get in the way of the electrons and slow them down just a little. As the electrons are slowed down by running into the atoms in the conductor, they generate heat. In fact, a heater is nothing more than a resistor designed to get really hot without melting. Resistance is measured in ohms.

Then there are semiconductors like silicon. This is what most electronic circuits are made of. It’s called a semiconductor because normally silicon has such a high resistance that current won’t flow. But it can be manufactured with other elements embedded inside the silicon so that the resistance can be controlled and changed. That means it will sometimes conduct electricity and sometimes not.

All three of the main concepts, voltage, current, and resistance are related so that if you have a 1 volt potential difference applied across a 1 ohm resistance, then you’ll get 1 amp of current.

Putting all this together, we get a simple formula called Ohm’s Law. The basic form is that voltage equals current times resistance. You can rearrange the formula however you want so it can also give you current equals voltage divided by resistance and that resistance equals voltage divided by current. The three main things to keep in mind are these:

◦ As the voltage goes up, so will the current.
◦ As the current goes up, so will the voltage.
◦ And as the resistance goes up, the current will go down.