How computers sense, decide, and act in the physical world — from thermostats to surgical robots, from microcontrollers to autonomous vehicles
Most students first experience computing through a screen. A person types, clicks, or taps — and a display responds. But a vast and consequential part of computing involves no screen at all. The thermostat on a wall reads temperature and controls a furnace. The antilock braking system in a car reads wheel speed forty times per second and adjusts brake pressure to prevent skidding. A pacemaker monitors heart rhythm and delivers precise electrical pulses when the rhythm is wrong. None of these systems display a web page. All of them run software.
This chapter introduces computing systems that operate in the physical world: systems that sense physical conditions, make computational decisions, and command physical actions. These systems automate tasks, control machines, enable robots, and run embedded inside everyday objects from washing machines to satellites.
By the end of this chapter, students will understand what automation is and how it works, how sensors translate physical quantities into data, how actuators translate instructions into physical effects, how control systems close the loop between sensing and acting, how feedback loops stabilize or destabilize systems, what robotics combines to build autonomous machines, what embedded systems are and how microcontrollers power them, and how safety and reliability concerns shape the design of physical computing systems. The chapter closes by examining automation as a social force — reshaping labor, raising questions about responsibility, and transforming the physical environment.
A greenhouse needs to water its plants automatically. How would a computing system know when to water? How would it turn the water on and off? What would happen if the sensor gave a wrong reading, or the valve stuck open? By the end of this chapter, you will be able to design the sensing, control logic, and safety features for exactly this kind of system — and understand why each piece matters.
Most of the computing students interact with daily happens on screens. A person types a message, the computer processes text, and a display shows a response. Input is a keystroke or tap. Output is pixels.
But a large part of computing — arguably the majority of computing activity in the world — has nothing to do with screens at all. The elevator listens for floor buttons, tracks position, opens and closes doors, and manages multiple competing requests. The washing machine checks water temperature, spin speed, and vibration while running through a programmed sequence of fill, wash, spin, and rinse. The traffic light cycles through states based on timers, sensors, and sometimes signals from emergency vehicles. None of these systems show a web page. All of them run software.
This is physical computing — computation embedded in things, operating on sensors, commanding motors and switches, running in real time, often without a human watching. It is one of the oldest and most widespread forms of computing in existence.
| Challenge | Description | Why It Matters |
|---|---|---|
| Timing | Responses must occur within strict time limits | A late response in a braking system can mean a crash |
| Limited resources | Many physical computers have kilobytes of memory, not gigabytes | Every byte must be used carefully |
| Physical failure | Software crashes have physical consequences | A bug in a medical device can injure a patient |
| Unpredictable environment | Temperature, vibration, humidity, and interference affect hardware | Software must survive real-world conditions |
The number of embedded processors in the world vastly exceeds the number of desktop and laptop computers. Physical computing is not a specialty — it is the dominant form of computation by volume.
Automation is the use of machines and programs to perform tasks with little or no direct human involvement at the moment of execution. The word has roots in the Greek autos, meaning self, carrying the sense of self-acting — a machine that acts on its own based on rules set in advance.
Automation is not new. Mechanical clocks automated time-keeping for centuries. Industrial looms used punched cards to control weaving patterns. What changed with digital computing was the scope, precision, and flexibility of automation. Digital computers can store complex programs, respond to varied inputs, adapt to changing conditions, and be reprogrammed without rebuilding hardware.
Every automated system requires three things. First, a defined goal or desired state — the system must know what it is trying to accomplish. Second, a way to observe conditions — the system must read the current state of the world; this is the role of sensors. Third, a way to act on conditions — the system must change the world to move toward the goal; this is the role of actuators.
If a system only observes without acting, it is monitoring. If a system only acts without observing, it is simple programmed control. True automation typically combines observation and action, closing the loop so the system can adjust its behavior based on what it measures.
| Form | Behavior | Example |
|---|---|---|
| Fixed | Same sequence every time, regardless of conditions | A timer-based sprinkler that runs at noon regardless of rainfall |
| Programmable | Different programs for different tasks; hardware stays the same | A CNC milling machine given a new program to cut a different part |
| Flexible | Adapts in real time based on sensor input | A climate system that adjusts airflow based on occupancy sensors |
| Intelligent | Uses decision algorithms or machine learning to handle unanticipated situations | An autonomous vehicle, an adaptive robot |
A sensor is a device that measures a physical quantity and converts it into a signal — usually an electrical signal — that a computing system can read. Sensors are the eyes and ears of automated systems. Without them, a computer has no information about the physical world and can only execute fixed instructions blindly.
| Physical Quantity | Sensor Type | Example Application |
|---|---|---|
| Temperature | Thermistor, thermocouple | Climate control, medical devices |
| Light | Photodiode, phototransistor | Automatic lighting, cameras, scanners |
| Sound | Microphone, piezoelectric sensor | Voice assistants, industrial monitoring |
| Pressure | Pressure transducer, barometer | Weather stations, tire pressure systems |
| Distance | Ultrasonic sensor, LiDAR | Parking sensors, obstacle detection |
| Acceleration | Accelerometer | Smartphones, airbag systems, robotics |
| Rotation | Encoder, gyroscope | Motor control, navigation, drones |
| Humidity | Capacitive humidity sensor | HVAC, weather stations |
| Chemical | Gas sensor, pH sensor | Air quality monitors, industrial safety |
Most sensors produce an analog signal — a continuously varying voltage that represents the measured quantity. As temperature rises, a temperature sensor produces a rising voltage. Digital computers, however, process binary numbers — discrete values. They cannot directly read a continuously varying voltage.
An analog-to-digital converter (ADC) solves this problem. It samples the sensor voltage at regular intervals and converts each sample to a binary number. The precision of this conversion is measured in bits. A 10-bit ADC produces values from 0 to 1023 (2¹⁰ − 1). A 12-bit ADC produces values from 0 to 4095. Higher bit depth means finer measurement resolution.
| Characteristic | Meaning | Example |
|---|---|---|
| Range | Minimum and maximum measurable values | −20°C to 60°C for a room thermometer |
| Resolution | Smallest detectable change | 0.1°C means it can distinguish 37.1°C from 37.2°C |
| Accuracy | How close the reading is to the true value | ±0.5°C means the reading may be off by half a degree |
| Response time | How quickly output changes after the quantity changes | A 10-second response time will miss a 5-second temperature spike |
| Noise | Small random variations in the signal | Averaging multiple readings reduces noise |
An actuator is a device that converts a signal from a computing system into physical motion or physical change. If sensors are inputs from the world to the computer, actuators are outputs from the computer to the world. Together, sensors and actuators make computation visible and consequential in physical reality.
| Actuator | What It Does | Application |
|---|---|---|
| DC motor | Spins at a speed proportional to applied voltage | Fans, wheels, conveyor belts |
| Stepper motor | Moves in precise increments for position control | 3D printers, CNC machines, telescopes |
| Servo motor | Holds a precise angle via built-in position sensing | Robotics, remote-controlled vehicles |
| Solenoid | Pushes or pulls a plunger when energized | Door locks, valves, printer mechanisms |
| Valve | Controls flow of liquid or gas | Irrigation, fuel injection, process control |
| Heating element | Converts electricity into heat | Ovens, water heaters, 3D printer hot ends |
| Speaker / buzzer | Converts electrical signals into sound | Alarms, voice output, notifications |
Microcontrollers are digital devices — they output only HIGH or LOW. But many actuators need analog-style variable control: a motor running at 60% speed, a heater at 40% power. Pulse-width modulation (PWM) bridges this gap by switching the actuator on and off very rapidly — hundreds or thousands of times per second. The ratio of on-time to off-time is the duty cycle. A 10% duty cycle motor runs slowly; 90% runs near full speed. The actuator's mechanical inertia smooths the switching into continuous behavior.
A control system is a system that uses sensors and actuators together to maintain a desired state or execute a desired behavior. Control systems are the computational heart of automation — they read sensor values, compare them to goals, and command actuators to move the physical state toward those goals.
Open-loop control executes actions without checking results. A toaster set to run for 2 minutes does not check the bread's color or temperature — it applies heat for the set time and stops. Open-loop control is simple and reliable but cannot compensate for variation or disturbances.
Closed-loop control reads sensor data to check whether the action is producing the intended result and adjusts accordingly. The thermostat is a closed-loop system: it reads temperature, compares it to the setpoint, and turns heating on or off to approach the goal. Closed-loop control can handle disturbances and variation. Most meaningful automation uses closed-loop control.
Open-Loop Control:
──────────────────────────────────────────────────────
Input → [ Program ] → Actuator → Physical Effect
(No feedback from the physical effect)
──────────────────────────────────────────────────────
Closed-Loop Control:
──────────────────────────────────────────────────────
Setpoint → (+) → [ Controller ] → Actuator → Physical Effect
↑ │
└──────── Sensor ◄─────────────────────┘
(Feedback)
──────────────────────────────────────────────────────
A closed-loop control system follows a repeating cycle: Sense → Compute → Act → Sense → Compute → Act → ... At each iteration: read sensors to get the current state; compare to the desired state; compute the appropriate action; command actuators; wait briefly; repeat. This cycle may run many times per second.
One of the most important control strategies is the proportional controller. The error is the difference between the desired setpoint and the actual measured value. The controller adjusts the actuator output proportionally to the error: when error is large, the response is strong; when error is small, the response is gentle.
error = setpoint − current_value
output = Kp × error
where Kp is the proportional gain — a constant that sets how strongly the system responds to error.
error = 20 − 14 = 6°C
output = 10 × 6 = 60 units (full heating)
error = 20 − 19 = 1°C
output = 10 × 1 = 10 units (gentle heating)
Real-world control systems often extend proportional control to PID control (Proportional, Integral, Derivative), which also accounts for accumulated past error (integral term) and the rate of change of error (derivative term). PID controllers are standard in industrial automation, motor control, and robotics. The mathematics belongs in advanced control engineering; the concept — that a controller can learn from history and anticipate change — is the key idea.
The closed-loop control system is an instance of a feedback loop — one of the most fundamental structures in engineering, biology, economics, and everyday life. A feedback loop exists whenever the output of a system is fed back as input to influence future behavior.
Negative feedback (also called corrective feedback) reduces the difference between the current state and the desired state. When the system drifts away from the goal, the feedback signal produces a corrective response that pushes it back. Negative feedback is stabilizing — it is the foundation of most control systems.
| System | Sensor Input | Actuator Output | Feedback Goal |
|---|---|---|---|
| Thermostat | Temperature | Heater / cooler | Maintain setpoint temperature |
| Cruise control | Vehicle speed | Engine throttle | Maintain setpoint speed |
| Autopilot | Altitude, heading | Control surfaces | Maintain flight path |
| Toilet tank | Water level | Fill valve | Maintain water level |
| Refrigerator | Interior temperature | Compressor | Maintain cool temperature |
| Blood glucose | Glucose level | Insulin / glucagon | Maintain glucose range |
Positive feedback amplifies a deviation. Instead of correcting, it reinforces. When output increases, the feedback signal causes further increase; when output decreases, the feedback causes further decrease. Positive feedback can be useful when rapid change is desired — electronic oscillators and some biological processes use it. But in control systems, unwanted positive feedback causes instability: the system spirals away from the desired state. A microphone held too close to its speaker produces the classic screech of audio feedback — positive feedback in an acoustic system.
A proportional controller set with too high a gain (Kp) can cause oscillation: the controller overcorrects, the value jumps above the setpoint, the error reverses, the controller corrects in the other direction, and the system bounces back and forth without ever settling. This oscillation is the key failure mode of poorly tuned proportional control.
Robotics is the field that designs, builds, and programs machines — robots — that can sense their environment, make decisions, and perform physical actions. A robot is typically defined as a machine that can sense, process information, and act. This distinguishes robots from simple automated machines, which follow fixed sequences without sensing.
| Component | Role | Examples |
|---|---|---|
| Mechanical structure | The physical body: arms, joints, wheels, legs | Arm links, chassis, end effectors |
| Sensors | The robot's ability to observe its environment and own state | Cameras, lidar, encoders, force sensors, IMUs |
| Actuators | Move the robot's body | Servo motors, hydraulics, pneumatics |
| Controller | The computing system that receives data and generates commands | Microcontroller, embedded computer, ROS |
| Software | Programs that interpret sensor data and generate actuator commands | Control loops, path planners, vision algorithms |
| Power supply | Provides energy | Batteries, cables, fuel cells |
A robot's degrees of freedom (DOF) is the number of independent ways it can move. A simple arm with one rotating joint has 1 DOF. A human arm has approximately 7 DOF — shoulder (3), elbow (1), wrist (3). Higher DOF enables more dexterous manipulation but requires more complex sensing and control. Most industrial robot arms have 6 DOF, which is sufficient to reach any position and orientation in space.
Industrial robots are fixed robotic arms in factories that weld, paint, assemble, pack, and move materials. They operate in carefully structured environments where every object's position is known in advance. They are fast, precise, and tireless, but poorly adapted to unpredictable environments.
Mobile robots move through space using wheels, legs, or tracks. Warehouse robots navigate grid floors to retrieve items. Research robots traverse rough terrain. Mobile robots must solve navigation: Where am I? Where am I going? How do I avoid obstacles?
Collaborative robots (cobots) work alongside humans. They include force-sensing systems that detect accidental contact with a person and immediately stop, preventing injury. Cobots are used in medical settings, light manufacturing, and laboratory automation.
Aerial robots (drones) use differential motor speeds across multiple rotors for balance and steering. Flight control requires gyroscopes, accelerometers, altimeters, GPS, and fast control loops running many times per second.
Surgical robots assist surgeons with enhanced precision, filtered tremor removal, and minimally invasive tool articulation. The surgeon controls the robot through a remote console; the robot translates commands into fine, precise movements at the surgical site.
A mobile robot navigating from point A to point B must solve a path planning problem: find a route that reaches the destination while avoiding obstacles. Simple approaches include grid-based search (represent the environment as a grid; use a search algorithm such as A* to find the shortest path through open cells) and potential fields (treat the goal as attracting the robot and obstacles as repelling it, then follow the computed force field). Path planning becomes far more complex in three dimensions, with moving obstacles, or with robots of complex geometry.
An embedded system is a computing system designed for one specific task or a narrow set of tasks, usually built into a larger device, and typically optimized for size, cost, and energy efficiency. Embedded systems run inside cars, appliances, medical devices, toys, industrial machines, consumer electronics, and office equipment. The number of embedded processors in the world vastly exceeds the number of desktops and laptops.
| Characteristic | Description |
|---|---|
| Single purpose | A washing machine controller does not run a spreadsheet. Specialization enables radical optimization. |
| Real-time operation | Must respond within predictable time limits. Hard real-time (airbag) means missed deadline = failure. Soft real-time (video) tolerates occasional delays. |
| Constrained resources | May have 4KB–256KB of flash and 256 bytes–8KB of RAM. Every byte matters. |
| Low power | A wireless sensor may run for two years on two AA batteries using careful sleep/wake cycles. |
| Physical durability | Must survive temperature extremes, vibration, humidity, and electromagnetic interference. |
The heart of most embedded systems is the microcontroller (MCU) — a single integrated circuit containing a processor, program memory, data memory, and peripheral controllers (ADCs, PWM generators, serial interfaces, timers) all on one chip. This differs fundamentally from a general-purpose computer, which uses separate chips for each function. The integration makes microcontrollers small, cheap, and energy-efficient.
┌─────────────────────────────────────────────────────┐
│ MICROCONTROLLER │
│ │
│ ┌──────────┐ ┌─────────┐ ┌──────────────────┐ │
│ │ CPU Core │ │ Flash │ │ SRAM │ │
│ │(Execute) │ │(Program)│ │ (Runtime) │ │
│ └──────────┘ └─────────┘ └──────────────────┘ │
│ │
│ ┌─────────┐ ┌──────┐ ┌───────┐ ┌──────────┐ │
│ │ GPIO │ │ ADC │ │ PWM │ │ Timers │ │
│ │ Pins │ │ │ │ │ │ │ │
│ └────┬────┘ └──┬───┘ └──┬────┘ └────┬─────┘ │
└───────┼──────────┼──────────┼─────────────┼──────────┘
│ │ │ │
Digital Analog PWM Timer
I/O Sensors Motors Events
Microcontrollers are traditionally programmed in C or C++, which produce efficient compiled code that runs directly on the hardware. Programming a microcontroller differs markedly from programming a general-purpose computer: there is often no operating system abstraction; memory is explicitly managed with no garbage collection; timing is the programmer's responsibility; and debugging may involve an LED blinking patterns rather than a display.
Arduino is a popular educational platform that simplifies embedded programming through a high-level library. The structure is a setup() function that runs once, followed by a loop() function that runs repeatedly — an infinite loop that is the heartbeat of the embedded system.
The Internet of Things (IoT) refers to physical devices — sensors, controllers, appliances — connected to the internet, enabling remote monitoring, control, and data collection. A smart thermostat is an IoT device: it has temperature sensors, a control program, wireless connectivity, and cloud integration that lets the homeowner adjust settings from a phone app.
IoT creates significant benefits — energy efficiency, remote infrastructure monitoring, smart medical devices — and significant risks. A connected camera with a weak password is an internet-accessible surveillance device. A connected medical device with a software vulnerability could theoretically be attacked. Security and privacy concerns around IoT are active and serious topics in cybersecurity research.
When computing controls physical systems, software failures can cause physical harm. Engineers systematically analyze what can go wrong and design systems to minimize consequences when something does.
| Failure Type | Description | Consequence Example |
|---|---|---|
| Sensor failure | Reading incorrectly, failing silent, or producing erratic data | A temperature sensor reading 1000°C shuts off heating permanently |
| Actuator failure | Stuck open, stuck closed, or stuck in place | A valve stuck open floods a system |
| Software failure | Bugs, unhandled exceptions, integer overflow, infinite loops | An overflow turns a small positive command into a huge one, driving actuator to extreme position |
| Power failure | Loss of power to the control system | Actuators stay in their current state, which may be hazardous |
| Communication failure | Loss of signal between distributed components | A subsystem continues on stale data or stops responding |
Fail-safe design means that when a failure occurs, the system goes to a state that minimizes harm. A crosswalk signal that loses power should show red, not green. A pressure relief valve that fails should fail open, releasing pressure rather than trapping it. A robotic arm that loses sensor data should stop moving, not continue blindly.
Redundancy means having backup systems that take over when primary systems fail. Aircraft flight control computers are typically triplicated — three separate computers compute the same answer from the same sensor data. If one disagrees, it is assumed faulty and ignored. This majority-voting design protects against single-component failures.
Watchdog timers are hardware timers that reset a system if the software does not periodically send an "I am still running correctly" signal. If the software crashes or hangs, the watchdog fires and restarts the system, preventing it from being stuck in a failed state indefinitely.
Interlocks are hardware or software conditions that prevent dangerous operations unless safety conditions are met. A machine guard interlock requires the safety door closed before motors can run. An elevator interlock prevents doors from opening unless the elevator is level with the floor.
Fail-safe design — failure goes to a harmless state
Redundancy — backup systems take over from failed primaries
Watchdog timer — hardware restart if software becomes unresponsive
Interlock — dangerous action blocked unless safety conditions are met
FMEA — systematic enumeration of every failure mode and its effect
LOOP every 10 minutes:
moisture = read_sensor(MOISTURE_SENSOR)
if moisture < 40:
open(WATER_VALVE)
flow = read_sensor(FLOW_SENSOR)
if flow == 0:
trigger_alert("Valve open but no flow")
wait(30 seconds)
close(WATER_VALVE)
else if moisture > 70:
close(WATER_VALVE) # ensure closed
| Failure | Safety Design |
|---|---|
| Sensor reads 0% always | Limit daily watering time; alert if valve open > 5 min |
| Sensor reads 100% always | Alert if moisture at maximum for 3+ consecutive days |
| Valve fails open | Flow sensor detects unexpected flow when valve should be closed |
| Power failure | Normally-closed solenoid springs shut automatically |
| Software crash | Watchdog timer restarts system within 24 hours |
error = 65 − 62 = 3
output = 2 × 3 = 6
speed change = 6 × 0.5 = 3 mph
new speed = 62 + 3 = 65 mph
error = 65 − 65 = 0
output = 2 × 0 = 0
speed change = 0
speed stays at 65 mph
Automation is one of the most significant forces shaping modern economies and daily life. It is worth stepping back from technical details to consider its broader consequences.
Automation enables production at scales impossible with hand labor. Pharmaceutical manufacturing requiring exact proportions, semiconductor fabrication at nanometer scales, and GPS positioning accurate to centimeters are all possible only through automation. Automation also enables work in environments dangerous to humans — robots now handle explosives, enter collapsed buildings, work in extreme heat, dive to crushing ocean depths, and operate in radioactive environments.
Every wave of automation has displaced human labor from some tasks while creating demand for labor in new tasks. Industrial automation displaced factory assembly workers. Agricultural automation displaced much farm labor. Office automation displaced clerical workers. The pattern is consistent: automation is most effective against tasks that are repetitive, predictable, and well-defined. The tasks automation displaces tend to be economically significant to the people performing them, and transitions cause genuine hardship even when the aggregate economy benefits.
Automation anxiety — fear that machines will permanently eliminate the need for human work — has recurred throughout industrial history. Historically, automation has transformed work rather than eliminated the need for it. Whether this pattern will continue with advanced AI and robotics is an active and genuinely uncertain question.
When an automated system causes harm, determining responsibility is complex. Was the fault in the sensor? The algorithm? The engineer who designed the system? The company that deployed it? The regulator who approved it? The operator who maintained it? These questions become especially acute with autonomous vehicles, automated medical devices, and AI-assisted decision systems. Automated systems are not neutral — they encode assumptions, design choices, and value judgments made by people. Responsibility for their effects — intended and unintended — belongs to the humans who create, deploy, and govern them.
┌──────────────────────────────────────────────────────┐ │ Physical World │ │ │ │ [Temperature / Position / Pressure / Speed / ...] │ │ ↓ ↑ │ │ SENSOR ACTUATOR │ │ (Read world) (Change world) │ │ ↓ ↑ │ │ ┌──────────────────────────────────────┐ │ │ │ CONTROLLER │ │ │ │ 1. Read sensor value │ │ │ │ 2. Compare to setpoint │ │ │ │ 3. Compute error │ │ │ │ 4. Compute output = Kp × error │ │ │ │ 5. Command actuator │ │ │ │ 6. Wait │ │ │ │ 7. Repeat │ │ │ └──────────────────────────────────────┘ │ └──────────────────────────────────────────────────────┘
Setpoint is 22°C. Temperature is 18°C. Calculate what error evaluates to with this code. What does output equal with Kp = 3? What does the heater do with a negative output? Identify the bug and write the corrected line.
Explain why changing the watering duration does not solve the fundamental problem. What architectural change to the system is needed?
Identify the security reasoning error. What principle does this violate? What two security measures should be implemented instead?
Chapter 24 showed how computing acts in the physical world — sensing, controlling, and automating. Many of the systems described in this chapter generate enormous quantities of data as they run. Sensor networks, embedded systems in cities and vehicles and factories, and IoT devices continuously produce streams of measurements. Chapter 25 introduces data science: the use of data, computation, statistics, and domain knowledge to ask and answer questions. Students will learn about datasets, features, data collection, cleaning, visualization, descriptive statistics, correlation and causation, prediction, and the bias and responsibility that come with data-driven decisions. The sensing work of Chapter 24 connects directly to the data work of Chapter 25.