Skip to Content
DraftsStage 1ComputationSwitches

Switches

Building a generic machine What could we base it on? What fundamental component do we need Modern digital computers are based on electronic switches These electronic switches are

Starting with something very simple, we can combine it into something much more capable

Starting with a switch you can control a light:

What if you connect multiple switches? Then all of them must be on for the light to be on:

This would be good for example if you launch a rocket and you want the checklist to be followed:

rocket NAV GO COM GO LAUNCH | battery - switch - switch - switch - ignition

If we combine switches in a different way, then only one OR the other needs to be on:

What else could we do? We could try making a calculator that can add numbers more accurately than we can

Unfortunately it seems like we’re going to need a lot of switches and lights just to add two single digit numbers:

0 1 1 battery - switch - switch - light 0 2 2 battery - switch - switch - light ... 1 9 10 battery - switch - switch - light ... 2 8 10 battery - switch - switch - light

Imagine if we want to add even larger numbers!

How can this be fixed?

Two steps:

First, one issue we were running into was that there are ten values for a single digit number:

0 1 2 3 4 5 6 7 8 9

This means when adding two single-digit numbers, there are a lot combinations (10 * 10 = 55)

What if instead we reduced the number of digits?

What if we reduced to only 0 and 1 digits and stopped using the other digits, then we’d have to deal with only 4 combinations

let’s focus on 0 and 1:

0 0 0 battery - switch - switch - light 0 1 0 battery - switch - switch - light 1 0 1 battery - switch - switch - light 1 1 ? battery - switch - switch - light

Here’s a problem, with 1 and 1 - we know the answer is 2 but we’re not using any digit other than 0 or 1, so what do we do?

Well with regular decimal digits, imagine a counter incrementing:

000 001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021

You can see that after 009, we change the next 0 -> 1, and 9 -> 0, then after 019 we change 1 -> 2, 9 -> 0. In other words we reset the last digit to 0 and increment the next place. Similarly once we get to 099, we get 100. This time we reset two 9s.

So in a similar way what if we’re only using 0 and 1, then we get the following

000 (0) 001 (1) 010 (2) 011 (3) 100 (4) 101 (5) 110 (6) 111 (7)

So after 001, we change the next 0 to 1 and reset the 1 to 0.

This is known as binary (bi -> 2) which is a different notation than regular decimal (dec -> 10)

And we have the answer to our question of 1 and 1 - it’s 10!

0 0 0 battery - switch - switch - light 0 1 1 battery - switch - switch - light 1 0 1 battery - switch - switch - light 1 1 10 battery - switch - switch - light

Much simpler and a lot fewer switches

Now to the second issue, how would we add two double digit numbers using only 0 and 1?

We could it this way:

00 00 00 battery - switch - switch - light 00 01 01 battery - switch - switch - light ... 11 11 110 battery - switch - switch - light

But that’s still a lot of switches, can we do it with fewer?

Let’s see what could help:

For now we’ve worked with switches that are controlled by a human, but what if a switch could be controlled by a wire instead?

battery - switch | | |-transistor-light

This doesn’t seem very useful at first, but the implications are necessary to be able to build large systems.

Say we want to know both if someone is ready, and if everyone is ready, previously we would need to have everyone keep two switches:

Person A At least 1 is ready batter +-[switch] --+ light +-[switch] | | | | +--o--------+ | | | Person B | | --[switch]---- Both are ready +----[switch]------light

But now with this transistor, everyone only needs to worry about a switch again

Person A At least 1 is ready batter +-[switch] -+-----| | | transistor--+light | | | | | transistor-| | | | | Person B | | +-[switch]--o-------+-----------| | | | | +-------| | |----------------transistor--transistor-light Both are ready

Now that we have only two digits 0 and 1, here’s another trick, what if when the switch is off, we consider it to represent 0 and when the switch is on, we consider it to represent 1?

First # batter +-[switch] -+-----| # | | transistor--+light | | | | | transistor-| | | | | Second # | | +-[switch]--o-------+-----------| | | | | +-------| | |----------------transistor--transistor-light Second #

When you do long addition, you have the concept of carrying to the next column:

1 123 348 --- 471

What if we did a similar thing?

First # batter +-[switch] -+-----| # | | transistor--+light | | | | | transistor-| | | | | Second # | | +-[switch]--o-------+-----------| | | | | +-------| | |----------------transistor--transistor-light Carry First # batter +-[switch] -+-----| # | | transistor--+light | | | | | transistor-| | | | | Second # | | +-[switch]--o-------+-----------| | | | | +-------| | |----------------transistor--transistor-light Carry

Subscribe for more

Get notified about new pages.
Unsubscribe anytime.