← Circuits with Tinkercad

Chapter 6 · Book pp. 95–112

Getting Started with Digital Circuits

ก้าวสู่การเรียนรู้วงจรดิจิทัลเบื้องต้น

Digital circuits are a must for anyone learning electronics. From the late 20th century into the 21st, digital technology grew fast and replaced many analogue devices. This chapter gives you the basics, in theory and practice: digital signals, the binary number system, and the basic logic gates.

6.1 Signal levels ระดับสัญญาณ

  • A digital signal has only two levels, high and low, called logic levels. A level near the supply voltage is logic “1” (high); a level near ground is logic “0”.
  • There are two big families: TTL and CMOS. They use different supplies.
  • TTL runs from 5 V ±5%. Below 0.8 V is “0”; 2 V and above is “1”.
  • CMOS runs from 3 to 18 V, so its levels are fractions of the supply: up to 1/3 Vcc is “0”, and 2/3 Vcc and above is “1”.
  • Between 0.8 and 2 V (TTL), or 1/3 and 2/3 Vcc (CMOS), the level is uncertain — it cannot be called “0” or “1”.
  • To cover both families, the experiments in this chapter use a 4.5 V supply.
Fig 6-1Signal levels that set the logic state: (a) TTL logic levels — “1” above 2 V, “0” below 0.8 V; (b) CMOS logic levels — “1” above 2/3 Vcc, “0” below 1/3 Vcc

6.2 Truth table ตารางความจริง

A truth table shows how a digital circuit behaves. It has two parts: the inputs on the left and the output on the right. Every digital design starts with its truth table.

InputsOutput
ABX
001
010
101
111
Fig 6-2An example truth table. The left side is the input (the conditions), the right side the output (what the circuit does)

Next: binary numbers →

6.3 The binary number system ระบบตัวเลขฐานสอง

Digital electronics is built on number systems. The basic one is binary (base 2); octal (base 8), decimal (base 10) and hexadecimal (base 16) were added for bigger calculations.

6.3.1 How many states?

Binary has only two digits, “0” and “1”: low–high, off–on. With more digits you get more states. Two lamps can be off-off, off-on, on-off and on-on: 4 states.

number of states = 2number of digits

2 digits → 2² = 4 · 3 digits → 2³ = 8 · 4 digits → 2⁴ = 16

6.3.2 Counting in binary

BinaryDecimal
00
11
102
113
BinaryDecimal
1004
1015
1106
1117
BinaryDecimal
10008
10019
101010
101111
BinaryDecimal
110012
110113
111014
111115
Fig 6-3Counting in binary compared with decimal, 0 to 15

6.3.3 Binary words

  1. Bit — one binary digit, 0 or 1.
  2. Byte — 8 bits. A computer handles data at least one byte (8 bits) at a time.
  3. LSB (Least Significant Bit) — the rightmost bit, with the lowest place value, 2⁰. If it is “1” it is worth 1 × 2⁰ = 1; if “0”, 0 × 2⁰ = 0.
  4. Naming the bits — the rightmost is bit 0 (b0, the LSB), then bit 1 (b1), and so on: b7 b6 b5 b4 b3 b2 b1 b0.
  5. MSB (Most Significant Bit) — the leftmost bit. In 8 bits it is bit 7, worth 2⁷ = 128. With 6, 5 or 4 bits its place value is 2⁵, 2⁴ or 2³.

6.3.4 Place values

In decimal, place values are powers of ten: units 10⁰ = 1, tens 10¹ = 10, hundreds 10² = 100. Binary works the same with powers of two: bit 0 is 2⁰ = 1, bit 1 is 2¹ = 2, bit 2 is 2² = 4, and so on.

BitPlace valueDecimalBitPlace valueDecimal
020142416
121252532
222462664
3238727128
Fig 6-4Place values of an 8-bit binary number in decimal, used for conversions

6.3.5 Binary to decimal

Example 6-1 · Convert 1011 to decimal

  1. Write the place values: b3 = 2³, b2 = 2², b1 = 2¹, b0 = 2⁰, over the digits 1 0 1 1.
  2. Multiply each digit by its place value and add: (1 × 2³) + (0 × 2²) + (1 × 2¹) + (1 × 2⁰) = 8 + 0 + 2 + 1 = 11.

6.3.6 Decimal to binary

Divide by 2 again and again and keep the remainders. The first remainder is the LSB (b0); the last is the MSB.

Example 6-2 · Convert 13 to binary

  1. 13 ÷ 2 = 6 remainder 1 → b0 (LSB) = 1
  2. 6 ÷ 2 = 3 remainder 0 → b1 = 0
  3. 3 ÷ 2 = 1 remainder 1 → b2 = 1
  4. 1 ÷ 2 = 0 remainder 1 → b3 (MSB) = 1

So 13 = 1101.

🔢 Try it: flip the bits

Next: the NOT gate →

6.4 The NOT gate นอตเกต

6.4.1 What it does

A NOT gate inverts its input: “0” becomes “1” and “1” becomes “0”.

Fig 6-5The NOT gate symbol and truth table: A = 0 → X = 1; A = 1 → X = 0

6.4.2 Testing the NOT gate IC

  • The NOT gate IC is the 74HC04, with six NOT gates inside. The test uses just one.
  • Input pin 1 has a 10 kΩ resistor to ground — a pull-down — so it is “0” whenever nothing else drives it. Then the output (pin 2) is “1” and LED1 lights.
  • A 4-position DIP switch (SW1) sets the input. Switch 4 ON connects pin 1 to the supply: “1” in, “0” out, LED1 off.
  • Switch it OFF and the pull-down gives “0” again, so the output is “1” and LED1 lights.
Fig 6-6Testing the NOT gate with the 74HC04: DIP switch SW1 (ON = 1, OFF = 0), R1 10k pull-down, R2 220 and LED1 on the output

🛠️ Lab 6.1 · Test the 74HC04 NOT gate

  1. Build Fig 6-7 in Tinkercad. Slide switch 4 ON and OFF and watch the LED.
    Switch 4 OFF → LED on. Switch 4 ON → LED off.
  2. Build it with real parts (Fig 6-8) and repeat step 1.
Fig 6-7Testing the 74HC04 NOT gate on Tinkercad by simulation
Fig 6-8The NOT gate test built with real parts on a breadboard. Scan the QR code for the demo video

Next: the NAND gate →

6.5 The NAND gate แนนด์เกต

6.5.1 What it does

A NAND gate multiplies (ANDs) its inputs and then inverts the result. If pins 1 and 2 are both “1”, 1 × 1 = 1, inverted to “0”. X = A·B.

Fig 6-9The NAND gate symbol and truth table: X is 0 only when A and B are both 1

6.5.2 Testing the NAND gate IC

  • The NAND IC is the 74HC00, with four NAND gates. The test uses one.
  • Inputs 1 and 2 have 10 kΩ pull-up resistors (R1, R2), so they are “1” unless a pushbutton connects them to ground.
  • The output, pin 3, drives LED1 through a 220 Ω resistor.
Fig 6-10A first NAND gate test: 74HC00 with pull-ups R1, R2 10k, pushbuttons S1 (A) and S2 (B), R3 220 and LED1

🛠️ Lab 6.2 · Test the 74HC00 NAND gate

  1. Build Fig 6-11 in Tinkercad. Press S1 and S2 and watch the LED.
    • No button pressed: A = 1, B = 1 → LED off.
    • Hold S1 only: A = 0, B = 1 → LED on.
    • Hold S2 only: A = 1, B = 0 → LED on.
    • Hold both: A = 0, B = 0 → LED on.
  2. Build it with real parts (Fig 6-12) and repeat step 1.
Fig 6-11Testing the 74HC00 NAND gate on Tinkercad by simulation (two 10k pull-ups, pushbuttons S1 and S2, a 220 resistor and LED, 4.5 V)
Fig 6-12The NAND gate test built with real parts. Scan the QR code for the demo video

6.5.3 A note on logic ICs

These tests use one gate and leave the other three inputs floating — fine for a short experiment. In a real design, connect every unused input to ground or to the supply. Unused outputs can be left unconnected.

Next: the NOR gate →

6.6 The NOR gate นอร์เกต

6.6.1 What it does

A NOR gate gives “1” only when every input is “0”. X = A+B.

Fig 6-13The NOR gate symbol and truth table: X is 1 only when A and B are both 0

6.6.2 Testing the NOR gate IC

  • The NOR IC is the 74HC02, with four gates. Here the inputs are pins 2 and 3 and the output is pin 1, driving LED1 through 220 Ω.
  • Both inputs start at “0”, held by pull-down resistors. Sliding a DIP switch ON makes that input “1”.
Fig 6-14Testing the 74HC02 NOR gate, shown by an LED on its output (DIP switch SW1 for A and B, R1 and R2 10k pull-downs, R3 220)

🛠️ Lab 6.3 · Test the 74HC02 NOR gate

  1. Build Fig 6-15 in Tinkercad. Switch DIP positions 1 and 4 step by step.
    • Neither on: inputs “00” → LED on.
    • Position 1 only: “10” → LED off.
    • Position 4 only: “01” → LED off.
    • Both on: “11” → LED off.
  2. Build it with real parts (Fig 6-16) and repeat step 1.
Fig 6-15Testing the 74HC02 NOR gate on Tinkercad by simulation
Fig 6-16The NOR gate test built with real parts. Scan the QR code for the demo video

Next: AND and OR →

6.7 The AND gate แอนด์เกต

6.7.1 What it does

An AND gate gives “1” only when every input is “1” — it multiplies the inputs. X = A·B.

Fig 6-17The AND gate symbol and truth table: X is 1 only when A and B are both 1

6.7.2 Testing it

  • The AND IC is the 74HC08, with four independent gates. Inputs pins 1 and 2, output pin 3.
  • LED off means the output is “0”; LED on means “1”.
  • Pull-down resistors hold the inputs at “0”; a DIP switch ON connects that input to “1”.
Fig 6-18Testing the 74HC08 AND gate (DIP switch SW1 for A and B, R1 and R2 10k pull-downs, R3 220, LED1)

🛠️ Lab 6.4 · Test the 74HC08 AND gate

  1. Build Fig 6-19 in Tinkercad and switch DIP positions 1 and 4 step by step.
    • Neither on: “00” → LED off.
    • Position 1 only: “10” → LED off.
    • Position 4 only: “01” → LED off.
    • Both on: “11” → LED on.
  2. Build it with real parts (Fig 6-20) and repeat step 1.
Fig 6-19Testing the 74HC08 AND gate on Tinkercad by simulation
Fig 6-20The AND gate test built with real parts. Scan the QR code for the demo video

6.8 The OR gate ออร์เกต

6.8.1 What it does

An OR gate gives “1” when any input is “1” — it adds the inputs. X = A+B.

Fig 6-21The OR gate symbol and truth table: X is 1 when A or B (or both) is 1

6.8.2 Testing it

The OR IC is the 74HC32, with four independent gates. Inputs are pins 1 and 2, output pin 3, with pull-down resistors on the inputs and an LED on the output.

Fig 6-22Testing the OR gate with the 74HC32 (DIP switch SW1 for A and B, R1 and R2 10k pull-downs, R3 220, LED1)

🛠️ Lab 6.5 · Test the 74HC32 OR gate

  1. Build Fig 6-23 in Tinkercad and switch DIP positions 1 and 4 step by step.
    • Neither on: “00” → LED off.
    • Position 1 only: “10” → LED on.
    • Position 4 only: “01” → LED on.
    • Both on: “11” → LED on.
  2. Build it with real parts (Fig 6-24) and repeat step 1.
Fig 6-23Testing the 74HC32 OR gate on Tinkercad by simulation
Fig 6-24The OR gate test built with real parts. Scan the QR code for the demo video

🔌 Try it: gate tester

Next: review →

All five gates

ABNOT ANANDNORANDOR
0011100
0111001
1001001
1100011
IC74HC0474HC0074HC0274HC0874HC32

🛠️ Activity · Practise conversions and gates

  1. Convert to decimal: 0110, 1001, 1111, 10000000.
  2. Convert to binary: 5, 10, 25, 100.
  3. How many states can 6 bits show? What is the place value of the MSB of a 6-bit number?
  4. Before testing each gate in Tinkercad, fill in its truth table on paper, then check every row with the DIP switch.
  5. Change the NAND test (Fig 6-11) to use pull-down resistors and switches to the supply, like the AND test. Does the truth table change?

Check yourself

Chapter 6 has two worked examples and the gate tests but no exercises, so these questions are my own, based on its pages.

1. In a TTL circuit, which voltage counts as logic “1”?
2. How many different states can 4 binary digits show?
3. What is binary 1011 in decimal?
4. What is decimal 13 in binary?
5. In an 8-bit number, what is the place value of the MSB (b7)?
6. In the NOT gate test (Fig 6-6), DIP switch 4 is OFF. What does the LED do, and why?
7. Which gate gives a “0” output only when both inputs are “1”?
8. Which gate gives a “1” output only when both inputs are “0”?
9. Which IC number holds four 2-input OR gates?
10. In a real design, what should you do with the inputs of the gates you do not use?