MicrocontrollerArduinoEmbedded
On this page

Activity 4.2.1 — Microcontrollers & Microprocessors


Learning Objectives

By the end of this lesson, students will be able to:

  1. Distinguish between microprocessors and microcontrollers
  2. Describe the internal architecture of a microcontroller
  3. Identify key features of the Arduino platform
  4. Compare discrete logic with microcontroller-based solutions
  5. Determine when to use each approach

Vocabulary

Vocabulary (click to expand)
TermDefinition
MicroprocessorA CPU-only chip that requires external memory and I/O
MicrocontrollerA complete computer on a single chip (CPU + memory + I/O)
CPUCentral Processing Unit - performs arithmetic and logic operations
RAMRandom Access Memory - volatile storage for data
ROM/FlashNon-volatile memory for program storage
I/O PortsInput/Output pins for connecting external devices
ADCAnalog-to-Digital Converter - converts analog signals to digital
IDEIntegrated Development Environment - software for writing/uploading code

Part 1: What is a Microprocessor?

Definition

A microprocessor (MPU) is the “brain” of a computer - it performs all arithmetic and logic operations. However, it cannot function alone.

Required External Components

A microprocessor needs external circuits to work:

ComponentFunction
ROMStores the program (permanent)
RAMStores temporary data
I/O ControllerManages input/output devices
Clock CircuitProvides timing signals
Bus ControllerManages data flow between components

Example: Intel 8086

The 8086 was an early microprocessor used in IBM PCs:

  • 16-bit data bus
  • 20-bit address bus
  • Required ~20+ external components to function

Advantages of Microprocessors

  • Very flexible
  • Can handle complex computations
  • Used in personal computers, servers

Disadvantages of Microprocessors

  • Requires many external components
  • More complex circuit design
  • Higher power consumption

Part 2: What is a Microcontroller?

Definition

A microcontroller (MCU) is a “computer on a chip” - it contains everything needed in a single package.

Microcontroller Architecture

┌─────────────────────────────────────────────────────────────┐
│                    MICROCONTROLLER                          │
│  ┌─────────┐    ┌─────────┐    ┌─────────┐    ┌─────────┐ │
│  │   CPU   │◀──▶│   RAM   │◀──▶│  Flash  │◀──▶│  I/O    │ │
│  │         │    │ (data)  │    │ (program)│   │  Ports  │ │
│  └─────────┘    └─────────┘    └─────────┘    └─────────┘ │
│       │                                           │        │
│  ┌────▼───────────────────────────────────────────▼────┐  │
│  │                    BUS SYSTEM                     │  │
│  └───────────────────────────────────────────────────┘  │
│                                                             │
│  Optional Peripherals:                                     │
│  - Timers/Counter      - ADC (Analog to Digital)          │
│  - Serial UART         - PWM generators                   │
│  - SPI/I2C bus         - interrupts                       │
└─────────────────────────────────────────────────────────────┘

Key Components

ComponentDescription
CPUExecutes program instructions
ROM/FlashStores the program (non-volatile)
RAMStores variables and temporary data
I/O PortsPins to connect LEDs, buttons, sensors
TimersGenerate precise time delays and intervals
ADCConvert analog voltages to digital values
MicrocontrollerManufacturerTypical Use
ATmega328PAtmel (Microchip)Arduino Uno
ATmega2560AtmelArduino Mega
STM32STMicroelectronicsSTM32 boards
ESP32EspressifWiFi/Bluetooth
PIC16MicrochipIndustrial

Part 2: Arduino as a Microcontroller Platform

Why Arduino?

Arduino is a popular microcontroller platform because:

  • Easy to use (beginner-friendly)
  • Open source hardware
  • Large community support
  • Inexpensive
  • USB programming

Arduino Uno Specifications

Arduino Uno R3

FeatureSpecification
MicrocontrollerATmega328P
Operating Voltage5V
Input Voltage7-12V (recommended)
Digital I/O Pins14 (6 provide PWM)
Analog Input Pins6
Flash Memory32 KB
SRAM2 KB
Clock Speed16 MHz
USBType-B connector

Arduino Board Layout

Arduino Uno pinout

                    Arduino UNO
    ┌────────────────────────────────────────────┐
    │                                            │
    │  USB        ┌──┐                          │
    │  Connector  │RST│  ← Reset button         │
    │             └──┘                          │
    │                                            │
    │  ┌─────▼───────────────────────────────┐   │
    │  │         Power & Analog Pins        │   │
    │  │ GND  AREF  SDA  SCL  [Analog]      │   │
    │  └────────────────────────────────────┘   │
    │                                            │
    │  ┌────────────────────────────────────┐   │
    │  │         Digital I/O Pins          │   │
    │  │  SCL  SDA  A0  A1  A2  A3  A4  A5  │   │
    │  │  └─────────▼─────────┘             │   │
    │  │         ~ pins = PWM               │   │
    │  └────────────────────────────────────┘   │
    │                                            │
    │  ┌────────────────────────────────────┐   │
    │  │      13──●──12  11●──10──●──9──●   │   │
    │  │       LED    Digital I/O          │   │
    │  └────────────────────────────────────┘   │
    │                                            │
    │      ┌──────┐    Power Jack               │
    │      │ Power│    (7-12V)                   │
    │      │ LED │                              │
    │      └──────┘                              │
    └────────────────────────────────────────────┘

Digital Pins

  • Pins 0-13: General purpose digital input/output
  • Pins with ~ (3,5,6,9,10,11): PWM output capability
  • Pin 13: Built-in LED

Analog Pins (A0-A5)

  • Read analog voltages (0-5V)
  • Convert to digital values (0-1023)

Power Pins

  • 5V: Regulated 5V output
  • 3.3V: Regulated 3.3V output
  • GND: Ground
  • Vin: Input voltage (same as power jack)

Part 3: Arduino Programming

The Arduino IDE

The Integrated Development Environment is used to write and upload code.

Basic Program Structure

// This runs once when Arduino powers up or resets
void setup() {
  // Configure pins, initialize components
  pinMode(13, OUTPUT);  // Set pin 13 as output
}

// This runs continuously while power is on
void loop() {
  digitalWrite(13, HIGH);  // Turn LED on
  delay(1000);              // Wait 1000ms (1 second)
  digitalWrite(13, LOW);   // Turn LED off
  delay(1000);              // Wait 1 second
}

Common Functions

FunctionDescriptionExample
pinMode(pin, mode)Configure pin as INPUT or OUTPUTpinMode(2, INPUT)
digitalWrite(pin, value)Set pin HIGH (5V) or LOW (0V)digitalWrite(3, HIGH)
digitalRead(pin)Read pin state (0 or 1)int value = digitalRead(4)
analogRead(pin)Read analog value (0-1023)int light = analogRead(A0)
analogWrite(pin, value)Write PWM (0-255)analogWrite(5, 128)
delay(ms)Wait in millisecondsdelay(500)

Part 4: Comparison - Discrete Logic vs Microcontroller

Discrete Logic Approach

What we’ve built so far in this course:

  • Flip-flops, counters, shift registers
  • Logic gates and combinational circuits
  • 74LS series integrated circuits

Advantages:

  • Pure digital electronics learning
  • Fast response (no software execution time)
  • Deterministic timing
  • Works without programming
  • No software bugs

Disadvantages:

  • Complex to design
  • Difficult to modify
  • Many components needed
  • Not flexible

Microcontroller Approach

What Arduino offers:

  • Software-based solution
  • Single chip replaces many ICs
  • Easily reprogrammed

Advantages:

  • Simpler circuit
  • Flexible (easy to change behavior)
  • Can implement complex logic
  • Faster development

Disadvantages:

  • Requires programming knowledge
  • Timing can be less precise
  • Software bugs possible
  • Slower response than hardware

When to Use Each Approach

ApplicationRecommended Approach
Simple counterEither (74LS163 or Arduino)
Complex state machineMicrocontroller
High-speed timingDiscrete logic
User interfaceMicrocontroller
Learning digital fundamentalsDiscrete logic
Commercial productEither (depends on volume/cost)

Key insight: In this course, you learn both approaches. Discrete logic teaches fundamental concepts, while microcontrollers prepare you for real-world engineering.


Part 5: Practice Problem

Problem Statement

You need to design a system that counts pulses from a sensor and displays the count on a 7-segment display.

Part A: Discrete Logic Implementation

List the components needed if using only digital logic (no microcontroller).

Part B: Arduino Implementation

List the components needed if using Arduino.

Compare the two approaches.

Show Solution

Part A: Discrete Logic Implementation

Components needed:

  • 74LS90 or 74LS163 (counter)
  • 7447 (BCD to 7-segment decoder)
  • 7-segment display
  • Additional logic for count limits
  • Pull resistors, capacitors

Part B: Arduino Implementation

Components needed:

  • Arduino Uno (or Nano)
  • 7-segment display (with driver or use multiplexing)
  • Sensor (connected to one digital pin)
  • (Optional) Shift register if using more displays

Comparison:

AspectDiscrete LogicArduino
ComponentsManyFew
Circuit complexityMediumLow
Programming neededNoYes
FlexibilityLowHigh
Learning valueHigh (fundamentals)Industry-relevant
Development timeMediumFast

Summary

  • A microprocessor is a CPU-only chip requiring external components
  • A microcontroller contains CPU + memory + I/O on one chip
  • Arduino is a popular, beginner-friendly microcontroller platform
  • Arduino has 14 digital I/O pins, 6 analog inputs, and 32KB Flash
  • setup() runs once at startup, loop() runs continuously
  • Use discrete logic to learn fundamentals, microcontrollers for real-world projects

Key Reminders

  • Microcontrollers combine multiple components into one chip
  • Arduino makes microcontrollers accessible to beginners
  • Both approaches have advantages and disadvantages
  • The next lessons will give you hands-on Arduino experience
  • Understanding both helps you choose the right tool for each job

Custom activity — adapted from PLTW Digital Electronics