How to Build an 8-bit Computer on a Breadboard

Ben Eater’s excellent series on building a computer from some basic components. It goes how things work from the transistors to latches and flip-flops to the architecture of the main circuits (clock, registers etc). The full playlist.

Other good resources include:

Circuit Basics

Studying voltage and current in circuits can start with two laws of conservation.

Note: Some of the links are dead, but this MIT Opencourse pdf has a detailed explanation. And Kahn Academy has some videos on the current laws as well.

  • KCL: Current flow into a node must equal the flow out of the node. (A node is a point on the wire connecting components in a circuit–usually a junction).
(KCL: Kirchoff's Current Law) Current flowing into any point on a circuit is equal to the current flowing out of it, A simple circuit with a voltage source (like a battery) and a resistor.
(KCL: Kirchoff’s Current Law) Current flowing into any point on a circuit is equal to the current flowing out of it, A simple circuit with a voltage source (like a battery) and a resistor.

  • KVC: The sum of all the voltage differences in a closed loop is zero.

KVL: The voltage difference across the battery (9 Volts) plus the voltage difference across the resistor (-9 Volts) is equal to zero.
KVL: The voltage difference across the battery (9 Volts) plus the voltage difference across the resistor (-9 Volts) is equal to zero.

Things get more interesting when we get away from simple circuits.

Current flow into a node (10 A) equals the flow out of the node (7 A + 3 A).
Current flow into a node (10 A) equals the flow out of the node (7 A + 3 A).

Note that the convention for drawing diagrams is that the current move from positive (+) to negative (-) terminals in a battery. This is opposite the actual flow of electrons in a typical wired circuit because the current is a measure of the movement of negatively charged electrons, but is used for historical reasons.

Based on the MIT OpenCourseWare Introduction to Electrical Engineering and Computer Science I Circuits 6.01SC Introduction to Electrical Engineering and Computer Science Spring 2011.

Arduino for Beginners

Arduino UNO connected to a breadboard from the starter kit.
Arduino UNO connected to a breadboard from the starter kit.

I’ve been avoiding working with the Arduino microcontrollers because I’d prefer to be able to program in Python with the Raspberry Pi (for example). However, since the 3d printer we just built this summer uses an Arduino for a brain, I broke down and picked up the Arduino Starter Kit (via Adafruit).

The Arduino Projects Book is an excellent resource for the beginner.
The Arduino Projects Book is an excellent resource for the beginner.

What I liked most about the Starter Kit most is the Arduino Projects Book that comes with it. It’s a wonderful introduction to circuits, electronics, circuit diagrams, and microcontrollers at the beginners level. If I offer an Arduino elective, I’ll use it as a textbook. Indeed, I’ll probably use bits of it as a reference when I teach circuits in middle school and Advanced Physics.

As for the programming, the basics, at least, are pretty straightforward. I got a blinking LED controlled by a switch input up an running pretty quickly. The code requires two loops, one to set up the inputs and the output, and a loop for the program to follow. The code below has a blinking light that’s controlled via pin 4, but changes to a solid light when the switch is pressed (the input for the switch is pin 2). The wiring for the circuit is shown in the picture at the top of the page.

blink_circuit

int switchOn = 0;

void setup(){
  pinMode(2, INPUT);
  pinMode(4, OUTPUT);
}

void loop(){
  switchOn = digitalRead(2);
  
  if (switchOn == HIGH) {
    digitalWrite(4, HIGH);
  } else {
    digitalWrite(4, LOW);
    delay(500);
    digitalWrite(4, HIGH);
    delay(200); 
  }
  
}

Resistance in Circuits

The greater the resistance (R) of a circuit, the less current (I) will flow through it (an inverse relationship). The equation is:

Current = Voltage / Resistance

I = \frac{V}{R}

An actual resistor. This one is 330 Ω with a tolerance of 5% (you can tell from the colors of the bands). Resistors are used to slow down the current moving through a circuit. Image by Nunikasi, via Wikipedia.

Resistors can be actual resistors, lamps, toasters, or anything else that uses electricity. Even the wires have resistance (but we don’t usually consider that since it’s small compared to the resistance of the other stuff).

The total resistance of a circuit depends on the way the resistors are arranged:

  • Series:
    • Add the resistances.
    • R = R_1 + R_2
    • More resistors in series reduce the amount of current in the circuit. (dimmer lights)
  • Parallel:
    • Add the inverse of the resistances to get the inverse of the total resistance.
    •  \frac{1}{R} = \frac{1}{R_1} + \frac{1}{R_2}
    • More resistors in parallel increase the amount of current used by the circuit. (brighter lights).
Comparing resistance and current in parallel circuits. Arranging the same resistors in parallel uses 4.5 times as much current (and energy) in this example.

(Notes: Current is a bit like water flowing through a pipe. Resistors are blockages that slow down the flow. Put two blockages, one after the other, and you reduce the flow rate. If you put two blockages into two different channels then though each one slows down flow the total flow is larger.)

As you put in more and more parallel circuits you draw more and more current until you overload the circuit and the wires heat up enough to burn through their insulation. Fuses (or circuit breakers) are used to prevent this; they burn out, breaking the circuit, when too much current goes through them.

Questions:

  • Why are appliances in your house almost always connected in parallel and not in series?
  • Which bulbs will be brighter: two bulbs in series, or two bulbs in parallel?
  • What are the total resistances and the total current that runs through the two circuits in the diagram?
  • What is the total power used by the two circuits in the diagram? Remember, Power = Voltage × Current