digital-logic-101

Digital Logic 101: Your First Steps with AND, OR, and NOT Gates

Denny Denny
9 min read
3D visualization of an AND logic gate with glowing internal circuitry.
The AND gate, a fundamental building block of digital logic, requires all inputs to be 'ON' for the output to be 'ON'.

The fastest way to learn digital logic is to build circuits. Reading truth tables is useful, but toggling switches and watching outputs change is where intuition forms. This tutorial walks you through building each of the three fundamental logic gates — NOT, AND, and OR — step by step in digisim.io. Every section ends with a working circuit you built yourself.

No prerequisites. No installations. Open a browser tab to digisim.io and follow along.

Before You Start: The Switch-to-Light Circuit

Every digital circuit has inputs and outputs. In digisim.io, the basic input is an INPUT_SWITCH (click to toggle between 0 and 1) and the basic output is an OUTPUT_LIGHT (glows when receiving a 1). Before touching any gates, build this minimal circuit to get comfortable with the interface.

Basic Switch and Light Demo

Build it:

  1. Open digisim.io/circuits/new.
  2. From the component palette, drag an Input Switch onto the canvas.
  3. Drag an Output Light to the right of it.
  4. Click the output node (small circle) on the switch and drag to the input node on the light. A wire appears.
  5. Click the switch to toggle it. The light follows: ON when the switch is 1, OFF when it is 0.

This confirms the fundamental idea: a digital signal flows from source to destination through a wire. Every circuit you build from here adds logic between the source and destination.

Try the Binary Basics


1. Build a NOT Gate Circuit (The Inverter)

The NOT gate takes a single input and flips it. Input 1 produces output 0. Input 0 produces output 1. It is the simplest gate, and building it first gives you confidence with the wiring workflow.

NOT Gate Component Diagram

Step-by-Step Build

  1. Place the input. Drag an Input Switch onto the left side of the canvas.
  2. Place the gate. Drag a NOT Gate from the Logic Gates section and position it to the right of the switch.
  3. Place the output. Drag an Output Light to the right of the NOT gate.
  4. Wire input to gate. Click the switch’s output node and drag to the NOT gate’s input node.
  5. Wire gate to output. Click the NOT gate’s output node and drag to the light’s input node.
  6. Test every input combination. There are only two:
Input (A)Expected Output (Y)What You Should See
01Switch OFF, Light ON
10Switch ON, Light OFF

Boolean expression:

Y=AY = \overline{A}

What You Learned

  • The NOT gate has exactly one input and one output.
  • It always produces the opposite of its input.
  • The small circle (bubble) on the gate symbol indicates inversion. You will see this bubble reappear on NAND and NOR gates later.

Practical Application: Active-Low Reset Lines

In microcontrollers and processors, reset pins are often “active low,” meaning the chip resets when the pin is pulled to 0. A NOT gate lets a designer convert a “press button = 1” signal into the active-low signal the chip expects. This pattern appears in virtually every embedded system.

Experiment with the NOT Gate


2. Build an AND Gate Circuit (The Gatekeeper)

The AND gate outputs 1 only when all inputs are 1. With two inputs, there are four possible combinations, and only one produces a 1 output. This makes the AND gate the natural choice for situations where multiple conditions must be satisfied simultaneously.

AND Gate Component Diagram

Step-by-Step Build

  1. Place two Input Switches on the left side of the canvas, one above the other. These are your inputs A and B.
  2. Place an AND Gate to the right, centered between the two switches.
  3. Place an Output Light to the right of the AND gate.
  4. Wire Switch A to the top input of the AND gate.
  5. Wire Switch B to the bottom input of the AND gate.
  6. Wire the AND gate’s output to the light.
  7. Systematically test all four combinations. Work through the truth table row by row:
Input AInput BExpected Output (Y)What You Should See
000Both OFF, Light OFF
010Only B ON, Light OFF
100Only A ON, Light OFF
111Both ON, Light ON

Boolean expression:

Y=ABY = A \cdot B

The AND operation behaves like multiplication: any zero in the inputs forces the output to zero.

What You Learned

  • The AND gate requires unanimity. Every input must agree on 1 for the output to be 1.
  • With nn inputs, an AND gate has 2n2^n possible input combinations, but only one produces a 1 output.
  • Testing all combinations systematically (not randomly) is how engineers verify correctness.

Common Pitfall: Floating Inputs

If you leave an AND gate input unconnected, you have a floating input. In physical circuits, floating inputs pick up electromagnetic noise and behave unpredictably. In digisim.io, the simulator handles this gracefully, but the habit of always connecting every pin matters when you move to real hardware. Use a CONSTANT component set to 0 or 1 if you need a fixed input value.

Practical Application: Two-Key Security System

The AND gate naturally models any system requiring simultaneous authorization. A bank vault needing two keys turned at once, a nuclear launch system requiring two officers, or a web application requiring both a password and a hardware token — all implement AND logic.

AND Gate Security System Template

Open Security Alarm Circuit


3. Build an OR Gate Circuit (The Inclusive Trigger)

The OR gate outputs 1 when at least one input is 1. It only outputs 0 when every input is 0. Where the AND gate enforces “all conditions required,” the OR gate enforces “any condition sufficient.”

OR Gate Component Diagram

Step-by-Step Build

  1. Place two Input Switches on the left.
  2. Place an OR Gate in the center.
  3. Place an Output Light on the right.
  4. Wire Switch A to the top input of the OR gate.
  5. Wire Switch B to the bottom input of the OR gate.
  6. Wire the OR gate’s output to the light.
  7. Test all four combinations:
Input AInput BExpected Output (Y)What You Should See
000Both OFF, Light OFF
011Only B ON, Light ON
101Only A ON, Light ON
111Both ON, Light ON

Boolean expression:

Y=A+BY = A + B

Note: this is logical OR, not arithmetic addition. In Boolean algebra, 1+1=11 + 1 = 1, because the output is already as HIGH as it can be.

What You Learned

  • The OR gate needs only one input to be 1 for the output to fire.
  • Three of the four input combinations produce a 1 output (contrast this with AND, where only one of four does).
  • The OR gate is the dual of the AND gate. De Morgan’s theorem formalizes this duality: A+B=AB\overline{A + B} = \overline{A} \cdot \overline{B}.

Practical Application: Emergency Stop Systems

Factory floors place emergency stop buttons at multiple stations around a machine. If any button is pressed, the machine must halt. This is OR logic: Button_1 OR Button_2 OR Button_3 = STOP. Adding more buttons simply adds more inputs to the OR gate.

Build an OR Alarm System


4. Combine All Three: Build an Enable Circuit

Now that you have built each gate individually, combine them into a circuit that demonstrates how gates work together. We will build an inverted enable circuit: a data signal passes through to the output only when an enable switch is ON, and the output is inverted.

Step-by-Step Build

  1. Place two Input Switches. Label one “Data” and the other “Enable” using the text tool.
  2. Place an AND Gate to the right.
  3. Place a NOT Gate after the AND gate.
  4. Place an Output Light at the end.
  5. Wire: Data switch to AND input A. Enable switch to AND input B. AND output to NOT input. NOT output to Light.
  6. Test the behavior:
    • Set Enable = 0. Toggle Data between 0 and 1. The light stays ON regardless (because the AND output is always 0, and the NOT inverts it to 1).
    • Set Enable = 1. Now toggle Data. When Data = 0, the AND outputs 0, the NOT outputs 1, and the light is ON. When Data = 1, the AND outputs 1, the NOT outputs 0, and the light is OFF.

Boolean expression for this circuit:

Y=ABY = \overline{A \cdot B}

You have just built a NAND gate from discrete AND and NOT components. The NAND gate is one of the most important gates in digital design. It is functionally complete on its own, meaning every other gate (AND, OR, NOT, XOR) can be constructed using only NAND gates.

What You Learned

  • Gates can be chained: the output of one gate feeds directly into the input of another.
  • Combining AND and NOT produces NAND, the universal gate.
  • Complex behavior emerges from simple, composable building blocks.

5. Verify Timing with the Oscilloscope

Static tests (toggle a switch, check the light) confirm logical correctness. But digital circuits operate in time, and understanding timing behavior separates functional designs from reliable ones.

The OSCILLOSCOPE in digisim.io lets you see how signals change over time, plotted as waveforms.

Step-by-Step Build

  1. Start with the AND gate circuit you built in Section 2.
  2. Replace one of the Input Switches with a CLOCK component. The clock automatically alternates between 0 and 1 at a fixed frequency.
  3. Keep the other Input Switch as a manual control.
  4. Add an OSCILLOSCOPE to the canvas.
  5. Connect one oscilloscope channel to the clock output (the rapidly toggling signal).
  6. Connect another channel to the AND gate output.
  7. Set the manual switch to 1 and observe: the oscilloscope shows the clock waveform on one channel and the AND gate output on another. They should match, because the AND gate passes the clock signal through when the other input is 1.
  8. Now flip the manual switch to 0. The AND gate output flatlines to 0, regardless of the clock. You have just used the AND gate as a signal gate, blocking a clock signal on command.

This is precisely how clock gating works inside real processors to reduce power consumption. When a functional unit is idle, its clock is gated off by an AND gate, stopping unnecessary switching and saving energy.

What You Learned

  • The oscilloscope reveals behavior that a static light cannot: timing relationships, propagation delay, and signal gating.
  • An AND gate can serve as a controllable pass/block for any digital signal.
  • Clock gating is a real power-saving technique in processor design, and you just demonstrated its core mechanism.

Quick Reference: The Three Gates at a Glance

GateInputsOutput RuleBoolean ExpressionKey Use
NOT1InvertY=AY = \overline{A}Signal inversion, active-low logic
AND2+All must be 1Y=ABY = A \cdot BConditional enable, masking
OR2+Any can be 1Y=A+BY = A + BMulti-source triggering

Next Steps

You now have hands-on experience with the three fundamental gates. From here, the natural progression is:

  1. NAND and NOR gates — You already built a NAND in Section 4. The NOR gate is an OR followed by NOT. Both are universal gates.
  2. XOR gate — Outputs 1 when inputs differ. Try building it from AND, OR, and NOT gates as a challenge.
  3. Half adder — Combine an XOR and an AND gate to add two single-bit numbers. This is the first step toward arithmetic circuits.
  4. Full adder — Chain half adders to handle carry bits, enabling multi-bit addition.

Each of these builds directly on the skills you practiced today. The key principle remains the same: place components, wire them, test systematically, and verify with the oscilloscope when timing matters.

Start Building Your Next Circuit