POLITEKNIK NEGERI MALANG
Department of Electrical Engineering
Digital Telecommunication Network Study Program
Introduction to
Microcontrollers
Dodit Suprianto
2025
Agenda / What You Will Learn
Today
• What is a Microcontroller? (And how is it different from a
Microprocessor?)
• Why are Microcontrollers so important? (Ubiquity and Applications)
• Key Components of a Microcontroller Unit (MCU)
• Overview of the Course Structure: Theory & Hands-on Labs
• Introduction to our Hardware & Software Tools
• Expectations and Roadmap
What is a Microcontroller? - The
"Brain" of an Embedded System
• Definition: A compact integrated circuit (IC) designed to govern a
specific operation in an embedded system.
• Analogy: A tiny, self-contained computer on a single chip.
• Core Idea: It takes inputs (from sensors, buttons), processes them
according to a programmed instruction set, and provides outputs (to
LEDs, motors, screens).
• Visual: Show a simple block diagram: Input -> MCU -> Output
Microcontroller vs. Microprocessor
(The Key Difference)
• Microprocessor (e.g., in your laptop):
• Is just the CPU. Requires external components: RAM, ROM, I/O ports, timers, etc.
• General-purpose, high processing power.
• Runs complex operating systems (Windows, macOS).
• Microcontroller:
• A complete computer on a chip. Contains CPU, RAM, ROM, I/O ports, timers, and
more.
• Single-purpose, low power consumption, cost-effective.
• Runs bare-metal code or a Real-Time OS (RTOS).
• Summary: Microprocessor is the brain needing a body; Microcontroller is
the brain with a body.
Why Should You Care?
Microcontrollers are
EVERYWHERE!
• Title: The Invisible Technology
• Collage of images showing:
• Consumer Electronics: Remote controls, smartwatches, toys.
• Home Appliances: Microwave ovens, washing machines, coffee makers.
• Automotive: Engine control units, airbags, anti-lock braking systems (ABS).
• IoT & Smart Devices: Thermostats, smart lights, sensors.
• Industrial: Robotics, assembly lines, power monitors.
• Message: You interact with dozens of microcontrollers every single
day.
Anatomy of a Microcontroller -
The Building Blocks
• Break down the internal architecture:
• Central Processing Unit (CPU): Executes instructions.
• Memory:
• Flash Memory (ROM): Stores the program code.
• SRAM (RAM): Stores temporary data (variables) during execution.
• EEPROM: Stores long-term data that must survive power loss.
• I/O Ports: Digital and Analog pins to interface with the outside world.
• Timers/Counters: Precisely measure time intervals, generate PWM signals.
• Analog-to-Digital Converter (ADC): Converts real-world analog signals (e.g.,
temperature) to digital values.
• Serial Communication Interfaces: UART, I2C, SPI for talking to other chips.
• Clock Generator: The heartbeat of the system.
A Real-World Example: The
ATmega328P (Arduino Uno's
MCU)
• Show a high-level block diagram of the
ATmega328P.
• Point out the key components from the
previous slide:
• CPU (AVR core)
• Flash (32KB), SRAM (2KB), EEPROM (1KB)
• Digital I/O Pins (14)
• ADC Channels (6)
• Timers (3)
• UART, I2C, SPI
• This makes the theory tangible.
A Real-World Example: The ESP32
(A Modern IoT Powerhouse)
Feature Category Specification
Significance &
Application
Handles complex tasks and
multiple operations
Dual-Core Xtensa® LX6 CPU
Core Processing simultaneously (e.g., running
(up to 240 MHz)
network stack and user code in
parallel).
Wi-Fi: 802.11 b/g/n (2.4 GHz) Enables seamless connection to
the internet (IoT) and
Wireless Connectivity Bluetooth: Classic & Low communication with phones,
Energy (BLE) speakers, and sensors.
ROM: 448 KB Ample space for complex
SRAM: 520 KB programs, network protocols,
Memory and data buffering. External
External Flash: Support up to
flash stores application code.
16MB
GPIO Pins: ~25+ digital pins Interfaces with buttons, LEDs,
Analog Input (ADC): 18 relays. Reads analog sensors
Input/Output channels (potentiometers, light sensors).
Analog Output (DAC): 2 Generates true analog signals for
channels audio.
Connects to a vast ecosystem of
peripherals: screens, SD cards,
Serial Communication UART, I2C, I2S, SPI, CAN
sensors, and automotive
systems.
Hall Effect Sensor: Detects magnetic fields. Creates
capacitive touch inputs.
Key Peripherals Touch Sensors: ~10 channels Measures internal chip
Temperature Sensor: temperature (approx.).
The Development Workflow:
From Code to Action
• Write Code: Use a text editor or IDE (e.g.,
Arduino IDE, PlatformIO, MPLAB X).
• Compile: Convert human-readable code
(C/C++) into machine code (hex file).
• Upload: Use a programmer/debugger to
transfer the hex file to the MCU's flash
memory.
• Execute: The MCU runs the program
autonomously.
• Debug/Iterate: Test, find bugs, fix code,
and repeat.
Required Tools & Software
• Hardware:
• Microcontroller Development Board (e.g., Arduino Uno, STM32 Nucleo, PIC
Explorer).
• USB Cable.
• Breadboard, Jumper Wires.
• Components: LEDs, resistors, sensors, motors.
• Software:
• Integrated Development Environment (IDE).
• Compiler Toolchain.
• Driver for the Programmer/Debugger.
Course Structure & Assessment
• Theory (40%):
• Understanding concepts, architecture, protocols.
• Quizzes and a Midterm Exam.
• Practical (60%):
• Lab reports demonstrating working circuits and clean code.
• Final Project (Design, Implementation, Demonstration).
• Textbooks & Resources: List key books and online forums (e.g.,
Arduino Forum, Stack Overflow, manufacturer datasheets).
Expectations & Tips for Success
• Come to Labs Prepared: Read the lab manual beforehand.
• Theory Informs Practice: Understand why the code works, not
just that it works.
• Datasheet is Your Best Friend: Learning to read a datasheet is a core
skill.
• Show a snippet of a datasheet (e.g., the pinout diagram).
• Debugging is a Skill: You will spend more time debugging than writing
code. Be patient and systematic.
• Ask for Help!
The Road Ahead: What's Next in
the Course?
• Module 1: Digital I/O - Controlling LEDs and reading buttons.
• Module 2: Analog I/O - ADC and PWM.
• Module 3: Timers and Interrupts.
• Module 4: Serial Communication (UART, I2C).
• Module 5: Sensors and Actuators.
• Module 6: Power Management and Final Project Workshop.