Microcontrollers & Embedded Systems

What is a Microcontroller?

A microcontroller is a compact integrated circuit designed to govern a specific operation in an embedded system. It contains a processor core, memory, and programmable input/output peripherals on a single chip.

Popular families include Arduino (ATmega), ESP32, STM32, PIC, and Raspberry Pi Pico (RP2040).

Microcontroller Architecture

Core Components

  • CPU: Executes program instructions (8-bit, 16-bit, or 32-bit)
  • Flash Memory: Stores program code (non-volatile)
  • RAM: Temporary data storage during execution
  • EEPROM: Stores configuration data that persists
  • Clock: Internal or external oscillator for timing

Peripherals

  • GPIO: General Purpose Input/Output pins
  • ADC: Analog-to-Digital Converter
  • DAC: Digital-to-Analog Converter
  • Timers: For delays, PWM, and event counting
  • UART, SPI, I2C: Communication protocols
  • PWM: Pulse Width Modulation outputs

Digital I/O Operations

Input Configuration

Reading digital signals (buttons, switches, sensors):

  • Pull-up: Default HIGH, button pulls to LOW
  • Pull-down: Default LOW, button pulls to HIGH
  • Floating: No defined state (avoid this)

Output Configuration

Controlling external devices (LEDs, relays, motors):

  • Push-pull: Can source and sink current
  • Open-drain: Can only sink current (needs pull-up)

Analog-to-Digital Conversion

ADCs convert analog voltage signals into digital values the microcontroller can process.

Resolution Calculation

For a 10-bit ADC with Vref = 5V:

Digital Value

Example: Reading 2.5V on 10-bit ADC with 5V reference = 512

Pulse Width Modulation (PWM)

PWM generates a square wave with variable duty cycle to simulate analog output.

Example: 50% duty cycle at 5V = 2.5V average

Applications: LED dimming, motor speed control, audio generation

Real-World Applications

  • Home Automation: Smart thermostats, lighting control, security systems
  • Automotive: Engine control units, airbag systems, infotainment
  • IoT Devices: Environmental sensors, wearables, smart meters
  • Robotics: Motor control, sensor fusion, autonomous navigation
Test Your Knowledge
Take this quiz to test your understanding. You need 80% or higher to pass and earn credit for this course.
5 questions80% required to pass