codeworking.org
Search
Course Syllabus (Lesson 02 of 03)
Computer Science Fundamentals • Module 01 14 min read

How a Computer Works: Electricity, Circuits & Bits

At its core, a computer is not a magical brain. A computer is an extremely fast machine made of billions of microscopic electric switches.

In this lesson, we will peel back the layers of technology and see how electricity flowing through wires turns into numbers, text, images, and programs.


1. The Lightbulb Analogy: Binary States

Imagine a simple lamp connected to a battery and a wall switch in your room:

State 0 • OFF 🌑
Open Circuit (Switch Open)
[ Battery ] ──[ _/ _ ]── [ Lamp: OFF ]
No electron current flows. Voltage is Low (0V) → Bit = 0.
State 1 • ON 💡
Closed Circuit (Switch Closed)
[ Battery ] ──[ ─── ]── [ Lamp: ON ]
Current flows continuously. Voltage is High (+3.3V/5V) → Bit = 1.
  • When the switch is open, no current flows: The lamp is OFF.
  • When the switch is closed, current flows: The lamp is ON.

In computer science, this is the fundamental unit of all digital information: the Bit (Binary Digit):

  • State 0: Voltage low (No current / False / Off).
  • State 1: Voltage high (Current flows / True / On).

A single switch can only represent 2 possibilities: 0 or 1. But what happens when you combine multiple switches together?


2. The Power of Multiple Switches

Number of Switches (Bits)Total Distinct Combinations (2ⁿ)Possible Values
1 Bit2¹ = 20, 1
2 Bits2² = 400, 01, 10, 11
3 Bits2³ = 8000, 001, 010, 011, 100, 101, 110, 111
8 Bits (1 Byte)2⁸ = 256Numbers from 0 to 255
32 Bits (4 Bytes)2³² ≈ 4.29 BillionIntegers from 0 to 4,294,967,295
64 Bits (8 Bytes)2⁶⁴ ≈ 18.4 QuintillionVirtually unlimited addressing space

With just 8 bits (1 Byte), you have 256 unique patterns — enough to assign a unique code to every letter in the English alphabet (capital and lowercase), every digit from 0–9, and every punctuation mark (the ASCII standard).

Letter 'A' = 01000001 (Decimal 65)
Letter 'B' = 01000010 (Decimal 66)
Letter 'C' = 01000011 (Decimal 67)

3. The Transistor: The World’s Smallest Electron Valve

In the 1940s, early computers used bulky glass vacuum tubes as switches. They generated extreme heat, burned out quickly, and filled entire rooms (like the 30-ton ENIAC computer).

In 1947, physicists at Bell Labs invented the Transistor.

Terminal 1 Source Electron supply input
Control Valve Gate (Silicon) Voltage opens/closes electron channel
Terminal 2 Drain Output signal (0V or +3.3V)

A transistor is an electronic switch made of a semiconductor material called silicon:

  • It has no moving mechanical parts.
  • It is controlled electronically: when you apply a tiny voltage to the middle terminal (the Gate), current flows between Source and Drain (1).
  • When you remove the voltage, current stops (0).

Scale and Speed

  • Modern microchips (like Apple M-series, AMD Ryzen, or Intel Core) pack over 50 to 100 billion transistors onto a silicon chip no larger than a fingernail.
  • A modern transistor can switch on and off over 3 to 5 billion times per second (3.0 GHz – 5.0 GHz).

4. How Does Binary Represent Complex Media?

How does a stream of 0s and 1s become a video, a 3D game, or music?

  1. Numbers: Written in base-2 binary positional notation (1, 2, 4, 8, 16, 32, 64, 128).
  2. Text: Character encoding tables (ASCII & UTF-8 Unicode) map binary numbers to letters and emojis (01000001A).
  3. Images: A screen is divided into millions of tiny dots called pixels. Each pixel has three color channels (Red, Green, Blue). Each channel is stored as an 8-bit number (0–255).
    • Pure White: RGB(255, 255, 255)
    • Pure Black: RGB(0, 0, 0)
    • Bright Blue: RGB(0, 102, 255)
  4. Sound: Microphone vibrations are sampled thousands of times per second (e.g. 44,100 samples/sec at 16-bit depth) into binary waves.

Key Takeaways

  1. Computers are entirely electronic machines operating on high voltage (1) and low voltage (0).
  2. A Bit is the smallest unit of data; 8 Bits make 1 Byte.
  3. The Transistor is the fundamental microscopic electronic switch powering all modern microprocessors.
  4. By combining billions of switches and agreed-upon binary encoding formats (ASCII, RGB, IEEE-754), computers can store and compute any media.

Next Step in the Curriculum

Now that you know how individual transistors turn on and off, how do we combine them to make logical decisions? In Lesson 03, we explore Boolean Logic and Logic Gates (AND, OR, NOT, XOR).

S

Computer Science educator, Software Engineer, Cloud Computing & Cloud Native Architect, and AI/ML Engineer. Founder & Owner of unus.one, softwork.ing, and codeworking.org.

Comments & Discussion