Skip to content
You Start with one site
Amounts in Start with one site
Engineering · Embedded Systems & Electronics

Digital Electronics and Logic

See what a microcontroller does with each line of your code: the gates, counters, memory and buses behind every register. Nine lessons with 74HC chips and LEDs on a breadboard, each tied to the firmware you write.

Found this useful?
The whole microcontroller on one chip. On top: the Cortex-M CPU, joined directly to the Flash, 64 KB of code, and the SRAM, 20 KB of data, all on the AHB and APB bus. Below are the peripherals: GPIO ports, a timer with PWM, an ADC, and the serial blocks SPI, I2C and UART, which reach the outside through pins, analog pins and serial pins.

You copy PORTB = 0x3F from an example and a pin does the wrong thing, because you cannot read the number. A sum comes out as 14 where you expected 30. A clock built on a timer loses a minute and a half a day. A data logger wears out its storage in a week. A new sensor returns nothing, and the code looks correct.

None of these is a fault you can find by reading the code again. In this course you build the circuits inside the chip from gates on a breadboard: adders, flip-flops, counters, shift registers. Then you find the same circuits in the timer, the memory, the buses and the ADC of the microcontroller you program, and the CPU that uses them all.

From a gate to the CPU
  1. 1Gates decideSeven gates simplified to one OR gate: fewer gates, less cost, less delay.
  2. 2Flip-flops rememberThe byte 0xB3 goes in one bit per clock pulse; one more pulse shows all eight bits on the LEDs at once.
  3. 3Counters keep time72 MHz divided by 7200 gives 10 kHz. A count of 0 to 999 overflows 10 times a second.
  4. 4The CPU uses them allint x = 5; from Flash through the CPU into SRAM.
You will be able to
  1. Read any register value in binary and hex, and set, clear or test its bits
  2. Build gates, adders, flip-flops, counters and shift registers, and find them inside a microcontroller
  3. Choose the memory, the bus and the ADC settings a design needs, and find a fault on the wires

New to this? New to digital electronics? Start with lesson 1: read a register value as the switches it sets.

You need A breadboard, a 5 V supply, LEDs, resistors, buttons and the 74HC chips of the parts list. Lesson 1 needs no parts.

Lessons
Lesson 1 · 14 minBinary, Hex, and Number SystemsRead a register value as the switches it sets: binary, hex, BCD and negative numbers.BinaryHexTwo's complementBit masks Lesson 2 · 15 minLogic Gates and Boolean AlgebraSix gates on a breadboard, every case tested with LEDs, and a circuit cut to fewer gates.Truth tablesDe MorganNAND onlyPropagation delay Lesson 3 · 14 minCombinational Logic CircuitsBuild a 4-to-1 multiplexer and a 2-bit adder from gates, then find them inside the chip.MultiplexerDecoderFull adderAddress decoding Lesson 4 · 14 minFlip-Flops, Latches, and RegistersA flip-flop keeps one bit, and a 74HC595 drives eight LEDs from three pins.LatchesD flip-flopShift register74HC595 Lesson 5 · 14 minCounters, Timers, and DividersA 4-bit counter on LEDs, and a clock halved at each stage: the timer inside your microcontroller.Ripple and synchronousPrescalerModulo-N74HC393 Lesson 6 · 12 minMemory Types and OrganizationHow SRAM, Flash and EEPROM each keep a bit, and a memory map that gives every register an address.SRAMFlash pagesEEPROM wearvolatile Lesson 7 · 14 minBus Architecture and InterfacesSPI, I2C and UART bit by bit, so that a logic analyzer capture shows the fault.SPI modesI2C acknowledgeUART framesPull-ups Lesson 8 · 13 minADC and DAC FundamentalsHow a voltage becomes a number: steps of 0.806 mV, a binary search, and the sample rate a fault needs.ResolutionSAR ADCNyquistR-2R and PWM Lesson 9 · 15 minMicrocontroller Architecture OverviewFollow int x = 5; from Flash through the CPU into SRAM, then the stack and interrupts.HarvardPipelineStackVector table
More about this course

Every number has a reason

A value in a register is not a code to copy. Each number sets bits, a time or a limit that you can check.

  • 0x3Fsix bits high and two low: each hex digit is four bits, so a value in a register reads as the switches it setsRegisters
  • 15 nsthe data sheet maximum for one 74HC gate, against 7 ns typical; five gates in a row take up to 75 ns, and a circuit timed on typical values can fail in a hot cabinetGate timing
  • 999, not 1000in the auto-reload register for a 1 ms tick from 1 MHz: the timer counts from 0, and 1000 makes each tick 0.1 percent long, 86.4 s a dayTimers
  • 100,000 writesthe life of an EEPROM cell; one address written every 3.3 ms uses them in under 6 minutes, so the writes are spread over many addressesMemory
  • 10 kHzthe least sample rate for a bearing tone near 5 kHz; a slower rate moves the tone to a wrong frequencySampling

Memory that forgets, and memory that wears out

SRAM
Fast, and gone at power off
  • Written byte by byte, without limit
  • Variables, the stack and the heap
  • A calibration kept here is lost at every power cut

The test: must the value survive a power cut?

Flash and EEPROM
Kept, but each write wears it
  • Flash: a whole page erased first, 10,000 to 100,000 cycles
  • EEPROM: one byte at a time, 100,000 to 1,000,000 cycles
  • Program code, settings and calibration

The test: how often will it be written?

What you work with

74HC chipsNAND, NOT, AND, OR and XOR gates, shift registers and a counter.
10 to 20 USD of partsA breadboard, LEDs, resistors, buttons and a 5 V supply.
Every case testedEach truth table checked with switches and LEDs.
Tied to your firmwareEach lesson ends where its circuit sits in the STM32 or the ATmega328P.
Not a prerequisiteEvery embedded course stands on its own. Come back here when a register puzzles you.
A logic analyzer helpsTo see SPI, I2C and UART bit by bit. Optional.

Honest limits. A logic analyzer shows a bus on the bench. In a deployed device the microcontroller can count what happens on its bus, how often a device gives a NACK and how long a transfer takes, and report the counts. A weak pull-up then shows as a rising error count before the device stops.

Before you start

  • No electronics course needed
  • Ohm's law and an LED with its resistor
  • Some C helps for the links to firmware
  • The parts list of the course, about 10 to 20 USD
The full course notes

This course shows you what happens inside the microcontroller when your code runs. You will build real circuits on a breadboard, watch logic signals with LEDs, and connect every concept back to the embedded programming you will do in other courses. Whether you are about to start your first embedded course or you have already written firmware and want to understand the hardware beneath it, this is your reference. #DigitalElectronics #LogicDesign #EmbeddedFoundations

This Is Not a Prerequisite

Jump straight into embedded programming

You do not need to complete this course before starting any of our embedded programming courses. Every embedded course (ATmega328P, STM32, ESP32, RPi Pico, RTOS) is designed to be self-contained. This course exists as helpful background that will make everything else easier to understand and as a reference you can come back to when you want deeper insight into what your code is doing at the hardware level.

What You Will Learn

Binary and Number Systems

How computers represent numbers. Binary, hexadecimal, BCD, and two’s complement signed integers. Read register values in hex and understand what each bit controls.

Logic Gates and Boolean Algebra

AND, OR, NOT, NAND, NOR, XOR. Truth tables, De Morgan’s theorems, and simplification. See how bitwise C operators map directly to physical gates.

Combinational and Sequential Circuits

Multiplexers, decoders, adders, flip-flops, shift registers, and counters. These are the building blocks of every peripheral inside your MCU.

Memory, Buses, ADC/DAC, and MCU Architecture

How SRAM, Flash, and EEPROM store data. How SPI, I2C, and UART work at the wire level. How ADCs convert analog voltages to digital values. How the CPU fetches and executes your instructions.

Lessons

Lesson 1: Binary, Hex, and Number Systems

Binary, Hex, and Number Systems. Count in binary and hexadecimal, convert between bases, understand BCD and two’s complement. Learn to read MCU register values in hex and know what each bit means. Practical: Convert register values, decode GPIO configuration bits.

Lesson 2: Logic Gates and Boolean Algebra

Logic Gates and Boolean Algebra. Build AND, OR, NOT, NAND, NOR, XOR circuits with 74HC series ICs. Verify truth tables with LEDs. Apply De Morgan’s theorems and simplify Boolean expressions. Practical: Wire logic gates on a breadboard, verify outputs with LEDs.

Lesson 3: Combinational Logic Circuits

Combinational Logic: Multiplexers, Decoders, Adders. Build multiplexers, decoders, encoders, and adders from gates. Understand how these circuits form the foundation of address decoding and arithmetic in a CPU. Practical: Build a 4-to-1 mux and a 2-bit adder on a breadboard.

Lesson 4: Flip-Flops, Latches, and Registers

Flip-Flops, Latches, and Registers. Move from combinational to sequential logic. SR latches, D flip-flops, JK flip-flops, shift registers, and parallel load registers. Drive 8 LEDs from 3 MCU pins using a 74HC595. Practical: Build a shift register LED driver with the 74HC595.

Lesson 5: Counters, Timers, and Frequency Dividers

Counters, Timers, and Frequency Dividers. Build ripple and synchronous counters, up/down counters, and frequency dividers. See how the timer/counter peripherals inside your MCU work at the gate level. Practical: Build a 4-bit binary counter with LEDs, divide a clock signal.

Lesson 6: Memory: SRAM, Flash, EEPROM

Memory: SRAM, Flash, EEPROM. Understand how SRAM cells store bits, how Flash uses floating gates, and how EEPROM provides byte-level erase. Explore address buses, data buses, and memory maps. Practical: Read an MCU memory map and locate peripheral registers.

Lesson 7: Bus Architecture and Communication Interfaces

Bus Architecture and Communication Interfaces. See SPI, I2C, and UART at the signal level. Understand clock polarity, data framing, acknowledge bits, and baud rates. Parallel vs serial bus tradeoffs. Practical: Trace SPI/I2C/UART signals with a logic analyzer or oscilloscope.

Lesson 8: ADC and DAC Fundamentals

ADC and DAC Fundamentals. Learn successive approximation ADC, resolution, quantization error, and the Nyquist sampling theorem. Explore R-2R ladder DACs and PWM as a pseudo-DAC. Practical: Calculate ADC resolution and quantization error for real sensors.

Lesson 9: Introduction to Microcontroller Architecture

Introduction to Microcontroller Architecture. Von Neumann vs Harvard, the ALU, registers, stack, program counter, and interrupt vector table. Trace what happens when you write int x = 5; down to the assembly level. Practical: Map C code to assembly instructions, locate GPIO registers in memory.

Parts Kit

All the components you need for hands-on exercises across the course:

PartQuantityFirst UsedApproximate Cost
Breadboard (full-size or half-size)1Lesson 22-3 USD
Jumper wire kit1 setLesson 22-3 USD
74HC00 (quad NAND)1Lesson 20.50 USD
74HC04 (hex inverter / NOT)1Lesson 20.50 USD
74HC08 (quad AND)1Lesson 20.50 USD
74HC32 (quad OR)1Lesson 20.50 USD
74HC86 (quad XOR)1Lesson 30.50 USD
74HC595 (8-bit shift register)2Lesson 41 USD
74HC164 (8-bit shift register, serial-in parallel-out)1Lesson 40.50 USD
74HC393 (dual 4-bit binary counter)1Lesson 50.50 USD
LEDs (red or green, 5mm)10Lesson 20.50 USD
Resistors (220 ohm for LEDs)10Lesson 20.25 USD
Resistors (10K ohm for pull-ups/pull-downs)10Lesson 20.25 USD
Push buttons (tactile, through-hole)4Lesson 20.50 USD
DIP switches (4-position or 8-position)1Lesson 30.50 USD
5V power supply (USB breakout or bench supply)1Lesson 21-2 USD

Total estimated cost: 10 to 20 USD depending on supplier and shipping.

Where This Connects

Every lesson in this course maps directly to concepts you will encounter in embedded programming:

Digital Electronics ConceptWhere You Will See It
Binary and hex notationEvery register configuration in every MCU
Logic gates and bitwise opsGPIO pin masking, flag checking, peripheral configuration
Multiplexers and decodersAddress decoding, peripheral selection on buses
Flip-flops and shift registersSPI communication, LED drivers, display interfaces
Counters and timersTimer/counter peripherals (PWM, input capture, output compare)
Memory types and organizationFlash programming, SRAM variables, EEPROM storage
SPI, I2C, UART at wire levelEvery communication peripheral in your MCU
ADC and DACSensor reading, analog output, signal processing
CPU architectureUnderstanding compiler output, debugging, optimization

Embedded Programming: ATmega328P

Start here for your first embedded programming course. 8-bit AVR, direct register access, and foundational projects.

Embedded Programming: STM32

Continue here for 32-bit ARM Cortex-M programming with HAL and register-level access.

© 2021-2026 SiliconWit®. All rights reserved.

9 lessons, in order.

SiliconWit makes these courses. We also run siliconwit.io, a monitoring service.