Main content

## Code.org

# Circuits & Logic

Adafruit founder Limor Fried and virtual reality designer Nat Brown show how simple logical circuits underlie everything your computer does.

## Want to join the conversation?

- So adders add up the sum of the two numbers (0,1 taken) the first couple of numbers in the 25+50 example make sense 1+0 = 1, 0+0= 0 , but then 1+1 = 0.... and 0+0=1 and sometimes 1+0 = 0 ? Can someone explain why these are different? I can't derive the correct sum (75)(12 votes)
- You know 3+6 = 9 and 8+7 = 15. Note that the second example uses two digits. That was the result of a
**carry**value of 1 from the addition of 8 and 7.

Likewise in binary: 01 + 01 = 10 it has to support carry operations also. That is what you see happening when you see 0+0 = 1 or 1+0 = 0, they are not mentioning the carry operations in the video, but they are present in the circuitry.(1 vote)

- What do or, xor, and nand do?

Edit what does or, and nand,xor,and not are used for?(7 votes)- OR tests if a value is true OR false:

true OR true = true

true OR false = true

false OR true = true

It is only false when both are false.

false OR false = false

XOR is either or, not both not neither:

true XOR true = false

true XOR false = true

false XOR true = true

false XOR false = false

NAND is basically what AND does, but inverts it:

true NAND true = false

true NAND false = true

false NAND true = true

false NAND false = false

*edit (my bad)*

false NAND false = true

Hope that helped :)(32 votes)

- how do i draw the required logic circuits?(4 votes)
- what wrong when my phone go to the water?(5 votes)
- so the more bits, circuits and adders you have the bigger calculations youre calculator can make on your'e pc?(3 votes)
- Correct!

Programming uses many logic operators to speedily make animations, games, and more!(4 votes)

- If electricity moves at almost the speed of light why would it make any difference if a computer is bigger than another? Since the speed of electricity can orbit the Earth in less than a second, why does it make such a big difference?(2 votes)
- besides speed of light (that's universal) there are other parameters that makes a computer faster than others clock speed is one of them .

Analogy : How fast the pizza is delivered is fixed by speed of light but how fast the pizza is cocked also matter here :-)(4 votes)

- how do circuits make it able to perform tasks in a lightning moment?(2 votes)
- Is there a limit to how many circuits they can use in the computer(2 votes)
- It depends on the size of the computer and the size of the circuits. Currently, many transistors are around 14nm in size with anywhere from 2-6 transistors making up one logic gate.(3 votes)

- why 1s and 0s instead of other numbers to run a computer(1 vote)
- Computers use electricity to store information. If there is electricity flowing, that represents a one. If there isn't electricity, that represents a zero. Since there are only two options, computers must use the binary number system.(4 votes)

- The computer has to produce electrical signals to represent binary values, thus process the information. Then how much electricity does a computer use to do things (such as send a text of 70 characters, screen display on with 1920 x 1080 for 5 mins...)? Is there any way to calculate exactly the electricity the computer needs to handle certain tasks?(2 votes)

## Video transcript

(Ding) (electric guitar music) - One of the coolest
things I've discovered about circuits is, circuitry
can be an art form. If I have a creative idea, I can get that creative
idea out using circuits. So, if you have ideas, you
can use technology to make those ideas come to life. Every input or output of
a computer is effectively a type of information,
which can be represented by on or off electrical signals. Or one's and zero's. In order to process the
information that comes in, as input, and the make the
information that's output. A computer needs to modify
and combine the input signals. To do this, a computer uses
millions of tiny electronic components, which come
together to form circuits. (upbeat music) - Let's take a closer look
at how circuits can modify and process information that's represented in one's and zero's. This is an incredibly simple circuit. It takes an electrical signal,
on or off, and it flips it. So, if the signal you give it is a one, the circuit gives it a zero. And if you give the circuit
a zero, it gives you a one. The signal that goes in, is
not the same as the signal that comes out. And so, we call the circuit, not. - More complicated circuits
can take multiple signals and combine them, and give
you a different result. In this example, a circuit will
take two electrical signals. Now, each one might be a one or a zero. If either of the signals
coming in is a zero, then the result is also a zero. This circuit will only give you a one if the first signal and the
second signal are both a one. And so, we call this circuit, and. There are many small circuits like this, that perform simple, logical calculations. But connecting these circuits together, we can make more complex circuits that perform more complex calculations. For example, you can make a
circuit that adds two bits together called, an adder. This circuit takes in two
individual bits, each one, a one or a zero, and adds them
together to calculate the sum. The sum can be zero plus zero equals zero, zero plus one equals one,
or one plus one equals two. You need two wires coming out
because it can take up to two binary digits to represent the sum. Once you have a single
adder for adding two bits of information, you can put
together multiples of these adder circuits side by side to add
together much larger numbers. - For example, here's how an eight bit adder adds the numbers 25 and 50. Each number is represented
using eight bits resulting in 16 different
electrical signals that go into the circuit. The circuit for an eight bit
adder has lots of little adders inside of it, which
together, calculate the sum. Different electrical circuits
can perform other simple calculations like subtraction
or multiplication. In fact, all the information
processing your computer does it's just lots and lots of small simple operations put together. Each individual operation
done by a computer is so, so simple, it
could be done by a human. But these circuits inside
computers are way, way faster. - Back in the day, these
circuits were big and clunky. An an eight bit adder
could be as big as a fridge and it would take minutes for them to perform a simple calculation. Today, computer circuits
are microscopic in size and way, way faster. Why are smaller computers also faster? - Well, because the
smaller the circuit is, the less distance the
electrical signal has to go. Electricity moves at just
about the speed of light which is why modern circuits can perform billions of calculations per second. - So, whether you're playing
a game, recording a video, or exploring the cosmos,
everything you can possibly do with technology requires lots of information to be processed extremely quickly. Underneath all this complexity, is just lots of teeny little
circuits that turn binary signals into websites and
videos, music and games. These circuits can even help us decode DNA to diagnose and cure disease. (upbeat music)