How To: Electricity/Electronics for Hackers: Basics: Part 3 (AC/DC, Ohm's Law, Electric Power).

Electricity/Electronics for Hackers: Basics: Part 3 (AC/DC, Ohm's Law, Electric Power).

Hello again, fellow hackers and electronic engineers! Welcome to part 3 of my Electricity/Electronics series. In previous parts, we already talked about what electricity is, the most important units in electricity, and the effects of electricity on the human body, as well as a shorter article where I explain how the electricity grid works. Today, we have quite a few subjects to look at, including:

  • The difference between AC/DC. A lot of you have been asking me to talk about this.
  • Ohm's law. This is the ABC of electricity. It is the most fundamental law in electric/electronic engineering
  • Electric power.

With that out of the way, let's get started! First thing we are going to talk about: direct and alternating current!

Direct Current

Direct current, or DC for short, is the most basic version of electricity. We already covered it a little bit in part 2 of this series. DC has a polarity, positive and negative, and the electrons always go in the same direction, from - to +. The voltage doesn't change either. Unlike Alternating Current (AC), DC is much more stable. And thus, it is used in TV's and computers, because the sensitive electronics inside it require a stable voltage.

The most common source of DC are batteries. Though it is also very common that AC is converted into DC. We will learn how to do that in our RPi power supply project. A perfect example of AC > DC conversion is your phone charger. It takes 220V AC from the outlet, steps it down to a lower voltage, and then turns it into a stable DC supply for your phone battery to use.

Since DC is the most basic form of electricity, there is not much to it. Here are the key things you need to remember about DC:

  • DC has a polarity, + and -.
  • DC only goes in one direction all the time.
  • The voltage of a DC power source always stays the same. (except for batteries when they are empty, of course.)

Here you can see DC in a graph:

Image via

And here you can view a simulation of DC I made using Java Circuit Simulator. There is one battery on the left acting as a DC source with a value of 12V, and a resistor of 100 ohm acting as a consumer. You can clearly see the current keeps going in the same direction, and that the voltage stays the same (12V).

Alternating Current

Let's now move on to Alternating Current, or AC for short. It is this form of electricity that comes out of your outlet in your house. The main difference between AC and DC is that AC, unlike DC, has no permanent polarity. The current of AC changes direction at a certain frequency. This frequency is expressed in Hertz, which means "cycles per second". In Europe, the frequency of the AC coming out of your outlet is 50 Hz (Hertz), in the US, it is 60 Hz. What this means is that if you live in Europe, the polarity of your outlet changes 100 times per second, and in the US, it changes 120 times per second.

To understand this more, let's look at a graph of how 230V AC at 50 Hz looks like, the default standard in Europe.

Image via

Remember how 1.5V DC (the voltage of an AA battery) looked like in a graph. The horizontal line once again represents the time, in miliseconds (ms) in this case, and the vertical line represents the voltage. To better understand how AC works, we can view it in steps:

1.) The voltage starts at 0V, and climbs up to 325V in 5 ms. You may be thinking: "But I thought that in the EU the voltage of an outlet was 230V, not 325V!". Technically, this is correct. The effective voltage (which can be compared to "average voltage"), is 230V, but it's peak is 325V. We call this peak the "amplitude". More on amplitude later.

2.) The voltage goes from it's peak voltage of 325V back to 0V, again in 5ms. Because the voltage went to a positive voltage (325V) and back to 0V, we call this part of the cycle the positive alternation, because the voltage is positive (pretty obvious, not?)

3.) Now, the voltage goes negative. To -325V. Then it goes back to 0V. This part of the cycle is known as the negative alternation, because the voltage is negative in this alternation (again, pretty obvious). In the negative alternation, the current goes the other way as it went in the positive alternation. The current goes "backwards".

4.) Now, we are back at step 1. We just completed a cycle. The amount of cycles per second is expressed in hertz or Hz for short.

Here I made a simulation of an AC circuit. The AC source on the left (the circle with the sine-wave in it) generates an effective voltage of 230V with an amplitude of 325V, and at a frequency (cycles per second) of 50Hz. Again, the standard in Europe. Here you can see how AC works: first, we read a positive voltage that increases and then again decreases. Then we get a negative voltage that decreases all the way to it's negative amplitude, and then again rises to 0V and so on... You can also see that when the voltage goes from positive to negative and vice versa, the current also changes directions. Here are a few key things to memorize about AC:

  • Has a changing polarity and voltage.
  • Has a frequency.
  • The direction in which the electrons flow changes.
  • Unlike DC, AC can only be generated using kinetic energy.
  • The voltage can be changed using transformers, unlike DC.
  • AC can not be stored, unlike DC (batteries).

There is much more to AC, but I will keep it at the basics for now. You now understand what AC is essentially, and that is enough for now. I just want you all to know that AC not only powers our homes, but that is also the thing that allows wireless communications! I will cover how that works in a later article.

Yes, AC literally drives the world!

Ohm's Law

Alright, we've reached the most important part of this entire series: Ohm's law. Ohm's law is the ABC of electricity, so it is VERY important for us to know! Let's begin:

We've already seen what voltage, current, and resistance is. But until now, we've seen them as 3 independant units. The thing is, there is a relation between voltage, current and resistance. This relation is known as "Ohm's law". Ohm's law says:

If voltage increases, so does current. If resistance increases, however, the amount of current drops.

To better help you understand this, I'll give you an example of a cyclist climbing a mountain. The speed of the cyclist is the current, the force he puts on his pedals is the voltage, and the pitch of the mountain he is climbing is the resistance. If the cyclist wants to mantain the same speed when the pitch increases, he will need to increase the force he puts on his pedals, or else he will slow down. When the cyclist wants to maintain the same speed when the pitch decreases, he will need to decrease the force he puts on his pedals, or he will go faster.

The same can be applied to electricity: say that we want to increase the amount of current in our circuit, we have 2 options: either we lower the resistance, or we increase the voltage. If we want to decrease the amount of current, we either need to decrease the amount of voltage, or increase the resistance. Here is a picture that you can use to better understand Ohm's law if you still don't get the concept:

Image via

As you can see, voltage is the force that pushes the electrons forward (or pulls them, in case of negative voltage), and the resistance is the thing that is slowing down the flow of electrons.

Using Ohm's Law

Alright, let's now see how we can calculate voltage, current, and resistance in a circuit! The basic formula for Ohm's law is:

U = I*R

Which means: voltage (U) equals current (I) multiplied by resistance (R). Let's calculate the amount of voltage needed for 1 ampere to flow in a circuit with a resistance of 1 ohm:

U = 1A * 1ohm = 1V.

Let's now apply this formula to something more practical.

Q: a lamp with an internal resistance of 766 ohm draws 0.3A. What is the voltage applied to this lamp?

A: U = I*R = 0.3A * 766ohm = 229,8V. When we round that up, we get 230V, the voltage used in residential homes in Europe.

There are other formulas too. You can also calculate resistance using this formula:

R = U/I.

Or current, using this formula:

I = U/R

You can remember all these formulas using the, what I call, "URIne pyramid" (a little bit innapropriate, but effective!).

Image via

Take not that "V" is the same as "U" in this picture: both stand for voltage.

Electric Power

You all most certainly heard the term "Watt" once in your life. But what is it? Watt is the unit that is used to express electric power. The symbol for electric power is "P", and the unit is Watt (W). So what is the formula for electric power? The formula for electric power is really simple:

P = U*I. Electric power equals voltage multiplied by current.

Let's again use a lamp, but this time one that draws 0.4A at 230V...

P = U*I = 230V * 0.4A = 92W.

The formula for electric power can also be used to calculate current:

I = P/U.

Or voltage:

U = P/I.

Combining Ohm's Law and Electric Power

Ohm's law and electric power can be combined to perform advanced calculations. Here is an example:

Q: A lamp of 102W uses 120V. Calculate the resistance of the lamp.

Alright, there are 2 things we already know:

P = 102W.
U = 120V.

And to get the resistance of the lamp, we would apply Ohm's law like this:

R = U/I.

But there is a problem... We do not know the current! Therefor, we must first calculate the current from the 2 parts of the electric power formula we can already use: wattage and voltage.

I = P/U = 102W/120V = 0.85A.

And now, we can apply Ohm's law:

R = U/I = 120V/0.85A = 141 ohm.


That was it for this part. In the next part, I will talk about some basic components that are used in pretty much every electric circuit. Like capacitors, diodes...

And sorry for anyone who has been waiting for this part for so long. I was studying the effects of electromagnetic induction for our EMP bomb. Good news: I will give the EMP bomb a try! Part 4 will not take as long as part 3.

Lastly, I am on twitter now! I will post updates about my articles and projects on my twitter page. If you wish to have a look, go here.

I hope everyone enjoyed the read! If you have any questions or feedback, feel free to comment below, or send me a PM!



This is pretty cool! Ohms law is awesome, and will probably help a lot of Null-Bytians with their projects.

Ohm's law is the foundation of electricity. Not only is it awesome, it is used in every electrical device. From electronics and computers to industrial appliances.

If you think Ohm's law was awesome, be prepared for electromagnetism and electromagnetic induction ;)


You're exciting me too much!

Great analysis of the insides of how electricity works. Love it!

Great job as always Pheonix! Really like the series.


Here is another great picture you could use for calculations when you get around to Watts.

This is indeed a good calculation chart, but it is kind of advanced. Right now I'm just trying to teach the basics first.

Thanks for sharing, though.


I've had a copy of this in my wallet for like 15 years, haha. (Minus the Russian.) :)

I never knew you took an interest in electricity?


A long, long time ago, I was an electrician for a few years. Still remember the basics, but that's about it.

You were an electrician? Awesome! What type of electrician? (household, industrial...)


great article.

just one thing the voltage of a DC current (power) source is not always the same, it depends on the resistance of the circuit.

What you are talking about is internal resistance of DC sources. internal resistance doesn't apply to "ideal sources", which is what I used in this article.

Though I need to say, an ideal source doesn't exist in the real world. But we use ideal sources to teach theory, which is what I did. Ideal sources don't have any internal resistance. Right now I am trying to teach the basics first, talking about internal resistance right away would confuse a lot of people!

Don't worry though, I will talk about internal resistance in later articles.


Hey Pheonix. I just remembered that I had a doubt in electricity. It is related to the application of superconductors. I don't even know how it sounds, but it has not been part of our course.

If we use a superconductor(R=0), and supply any amount of current(>0), would that mean infinite electricity? Or am I missing something?

-The Joker

It would just generate a gigantic short circuit. Remember that electricity is an inbalance of protons and electrons. When the electrons and protons reach balance again, the potential difference is 0 (and so is the voltage), so there is no electricity left.

You'd create an almost infinite current that would last for about +/- a few nanoseconds and vaporize the wires in the process, but that's about it.

If you're talking about circuits which have a resistance (a consumer), you won't generate infinite electricity. You will save energy on the superconductors, but the consumer still consumes electricity. In electric circuits, you always lose energy.

Besides, the amount of energy we put into creating superconductors is much higher than the energy we save from it.

Hope I answered your questions.


So, in other words, does that mean that the superconductors'd save energy but the electric appliances will use it and thus we won't have unlimited energy?

There was a small paragraph in the book for it that said in a closed superconductor circuit, the current would continue to flow on forever. And it said the record to be about 200K at which we can use them.

But I'm saying at a temperature at which we could use it, be it room temperature at 298K. It should not be completely impossible, just not invented yet.

But there's more to it. Voltage supplied is in volts and electricity consumed is in Ampere. R=0'd mean that I=Infinite, and we get infinite electricity. But of course, that seems too good to be true, unless what you meant was the first paragraph of my (this) comment.

P.S.:My favourite topic in Physics is of Quantum Mechanics, especially about Negative Energy, Wormholes and Mass-Energy Conversion(Relativity), and not Electricity. So forgive me if the questions sound lame.

-The Joker

First, the amount of electricity consumed is not measured in amperes. It is measured in Ampere-seconds (As) or Ampere-hours (Ah). The formula for Ampere-seconds is simple:

Q = I * t (time in seconds).

There is no way for infinite electricity to exist. Again, electricity is just an imbalance between protons and electrons. If you short the positive and negative terminals with superconductors, all electrons will just flow from - to + instantly and the source will be empty.

When doing this with AC, the current will be so high the generator on the other end will simply blow up.

And yes, there will be no loss over the superconductors, but the appliance will still convert the electric energy to something else.

You should look up "the law of conversion of energy". Which basically tells us that energy can not be generated nor can it be thrown away, it can only be converted to other forms of energy.

And yes, we'd get an infinite current at 0 ohm, but that wouldn't last very long. probably not even a nanosecond.


Now I got it! You mean that no resistance will make current flow at incredible speed which will be too much for our battery to handle, else the appliance will still consume energy!

But you destroyed my hopes :'(
BTW, the conservation laws are rather ambiguous. Most of them don't work at small scales.

-The Joker

glad to see you got it!

the conservation doesn't work on small scale? The law of conservation of energy applies everywhere!


I mean a VERY small scale. Law of conservation of information is more basic. Some examples would be mass energy conversion, and uniform negative energy throughout space not getting used up. Yet even that law is under debate, whether it applies everywhere. But those are astrophysics and quantum mechanics. It is universal for classical mechanics though.

-The Joker

Well, I don't know anything about astrophysics or quantum mechanics. The more you know!


My favourite part is the string theory proposing number of dimensions in a universe to be either 10 or 26 and thus the infinite parallel 4 dimensional space time continuums for us.

-The Joker

I think you should explain Tesla coil in the next part (which wasn't actually discovered by Tesla).

-The Joker

Tesla did invent the Tesla coil. The effect the Tesla coil uses was not discovered by him, yes, but he still did invent it.

The next article will probably be about electromagnetism and electromagnetic induction, aswell as the explanation of some basic electronic components (like diodes and capacitors).


That's what they say. But these things sound too strange to be true, since science hasn't been properly organised till a few decades ago.

-The Joker

Share Your Thoughts

  • Hot
  • Latest