Lecture-06: Input–Output (I/O) Devices and
I/O System in Computer Fundamentals
1. Introduction to I/O Devices
Input–Output (I/O) devices are the components that allow a computer to communicate with the
external world.
Input Devices → Send data to the computer.
Examples: Keyboard, Mouse, Scanner, Microphone.
Output Devices → Receive data from the computer.
Examples: Monitor, Printer, Speaker.
I/O Devices → Some are both input and output.
Examples: Touchscreen, Modem.
I/O devices are essential because the CPU alone cannot directly take data from users or show
results.
2. I/O System Architecture
The I/O system includes:
1. I/O Devices
2. Device Controllers
3. Device Drivers
4. System Bus (Data, Address, Control lines)
5. Operating System I/O Subsystem
2.1 Device Controller
Each I/O device is connected to the system through a controller (or adapter card).
Functions:
Converts device-specific signals to computer-readable signals
Handles buffering
Manages data transfer
Examples: Disk controller, Keyboard controller.
2.2 Device Driver
This is software in the OS.
It:
Provides a standard interface to the OS
Translates OS commands into device-specific instructions
Handles errors from the device
e.g., mouse driver, keyboard driver, printer driver.
2.3 System Bus
All I/O components communicate through:
Address Bus → selects device location
Data Bus → transfers actual data
Control Bus → sends device control signals
3. I/O Data Transfer Techniques
Three major I/O communication methods:
3.1 Programmed I/O
CPU controls I/O directly
CPU waits until the device is ready
Slow and inefficient
3.2 Interrupt-Driven I/O
Device interrupts CPU when ready
CPU does not wait
Efficient for keyboards, mice, etc.
3.3 Direct Memory Access (DMA)
Data transferred directly between device and memory
CPU not involved for each byte
Used by high-speed devices (hard disks, network cards)
4. How the Keyboard Works
A keyboard is an input device that uses an internal circuit and a microcontroller to detect which
key is pressed.
4.1 Keyboard Internal Structure
Most keyboards use a keyboard matrix:
Rows (R1, R2, R3…)
Columns (C1, C2, C3…)
Each key lies at the intersection of a row and a column.
Example:
Key A → Row 3, Column 2.
4.2 Process: How a Keystroke Reaches the Computer
Step 1: Key Press Detection
Pressing a key completes an electrical circuit between a specific row and column.
The keyboard microcontroller continuously "scans" the matrix (Scanning).
Step 2: Keyboard Controller Generates a Scan Code
Each key has a unique scan code (NOT the same as ASCII).
Example:
Key "A" → Scan code 0x1C
Key "Enter" → Scan code 0x1C
The keyboard sends:
Make Code (when key is pressed)
Break Code (when key is released)
Step 3: Scan Code is Sent to the PC
Communication protocol:
USB Keyboard
PS/2 Keyboard
Data transferred using interrupt-driven I/O.
Step 4: Keyboard Controller (8042/modern equivalent) Receives the Code
The controller signals the CPU through an interrupt (IRQ1).
Step 5: Device Driver Converts Scan Code to ASCII/Unicode
OS uses keyboard driver + language layout.
Example:
Scan code 0x1C → ASCII 'a' (if English layout)
Can become 'আ' or 'অ' if Bangla layout is active.
Step 6: OS Sends the Character to the Active Application
Thus typing appears instantly in:
Text editor
Search bar
Web form
5. How the Mouse Works
A mouse is an input device that detects:
movement (X, Y coordinates)
button presses
scroll wheel data
5.1 Mouse Types
Mechanical mouse (old) – Ball rotates sensors
Optical mouse (most common) – LED + CMOS sensor
Laser mouse – More accurate
5.2 How an Optical Mouse Detects Movement
1. A light source (LED or laser) shines on the surface.
2. The CMOS sensor takes thousands of images per second.
3. A DSP (Digital Signal Processor) compares images to detect motion vectors.
4. It calculates:
o ΔX (movement in X-axis)
o ΔY (movement in Y-axis)
5. Data is sent to the computer through USB or Bluetooth.
Example:
Move mouse 5 mm right → DSP calculates ΔX = +20 units
Cursor moves accordingly.
5.3 Buttons & Scroll Wheel
Mouse has microswitches.
Left-button click → sends a “button pressed” signal
Scroll wheel → rotary encoder sends scroll pulses
5.4 Mouse Data Transfer to PC
Mouse sends:
Movement packets (X, Y)
Button packet
Scroll packet
This usually uses interrupt-driven I/O.
6. Other Common I/O Devices (Short
Overview)
6.1 Monitor (Output Device)
LED/LCD technology
Uses graphics controller
Displays pixels from frame buffer
6.2 Printer (Output Device)
Laser printers use drum + toner
Inkjet sprays micro-droplets
Printer driver converts document into pixels
6.3 Scanner (Input Device)
CCD/CMOS sensor
Converts analog light intensity → digital image
6.4 Storage Devices (I/O Devices)
Hard disk / SSD uses:
Controller
Cache
DMA for data transfer
7. I/O Management in the Operating System
OS handles complex I/O operations using:
7.1 Buffering
Temporary storage to reduce waiting.
7.2 Spooling
Printer spooling allows multiple jobs to queue.
7.3 Caching
Speeds up access by storing frequently used data.
7.4 I/O Scheduling
Decides order of device access (e.g., disk scheduling).
8. Summary
I/O devices connect the computer to the outside world.
Keyboard uses a scan matrix → creates scan codes → interrupt → driver converts to
ASCII.
Mouse uses optical sensors → detects movement → sends packets to PC.
I/O system includes controllers, drivers, buses, and OS-level management.
Data transfer occurs through programmed I/O, interrupt-driven I/O, or DMA.