What is an embedded system?
An embedded system is a computer built inside another product to do one fixed job. You do not see it as a computer.
- Examples: washing machine, microwave, digital watch, car airbag, traffic lights, fitness band.
- It is small, cheap, uses little power and must react quickly (often in real time).
Microcontroller
The brain is a microcontroller: one chip with a processor, memory (to store the program and data) and input/output pins. A normal PC uses a microprocessor, which needs separate memory chips.
Hobby and school boards (such as Arduino-style boards or micro:bit-style boards) put a microcontroller on a board with pins, a USB port and a power supply.
Sensors and actuators
Every embedded system follows input → process → output.
Sensors (input)
- Light sensor (LDR), temperature sensor, push switch, motion (PIR) sensor, ultrasonic distance sensor, moisture sensor.
- Digital sensors give 0 or 1 (button pressed or not). Analogue sensors give a range; the board's ADC turns it into a number, e.g. 0–1023 for 10 bits.
Actuators (output)
- LED, buzzer, DC motor, servo motor (turns to an angle), relay (switches a big load), display screen.
- Motors need more current than a pin can give, so a transistor or motor driver is used.
Programming embedded systems
Most programs have two parts: setup (runs once) and loop (runs forever).
setup: make pin 13 an output
loop:
light = read sensor
if light < 300:
LED on
else:
LED off
wait 100 ms- Variables store values (light, limit, count).
- Conditions (if / else) choose what to do.
- Loops repeat checks.
- Event-driven programs react when something happens (a button press, a timer, a message) instead of checking all the time. This saves power.
A flowchart or state diagram helps plan the program before writing code. Test it, then debug.
Smart objects and protocols
A smart object is an embedded system that talks to other devices: the Internet of Things (IoT).
- Wired: serial (UART), I²C and SPI link chips on one board.
- Wireless: Bluetooth (short range, phones), Wi-Fi (home network, internet), Zigbee/LoRa (low power, long life sensors).
- A protocol is an agreed set of rules for sending data: speed, message format and error checks.
Things to think about: battery life, cost, safety and data privacy.
Key formulas and definitions
- Key term: embedded system — a dedicated computer inside a product
- Key term: microcontroller — CPU + memory + I/O on one chip
- Key term: sensor (input) / actuator (output)
- ADC value = (V / Vref) × (2ⁿ − 1)
- Key term: event-driven — code runs when an event happens
- Key term: protocol — agreed rules for data exchange
Worked examples
1. Name the input, process and output in an automatic street light.
Input: light sensor. Process: microcontroller checks if light is below a limit. Output: lamp switched on through a relay.
2. A 10-bit ADC with 5 V reference reads 2.5 V. What number does it give?
(2.5/5) × 1023 ≈ 511.
3. Write a rule so a fan runs above 30 °C.
if temperature > 30: fan on, else: fan off — inside the loop.
4. Why use an event (interrupt) for a door button instead of checking in the loop?
The board can sleep and wake only when the button is pressed, saving battery and never missing a quick press.
5. A soil sensor gives 0 (wet) to 1023 (dry). Plan a plant-watering system.
Loop: read sensor; if value > 700, switch pump on for 3 s; wait 10 minutes; repeat.
Common mistakes
- Thinking an embedded system is a full PC. It does one job and has no keyboard or screen in most cases.
- Mixing up sensors and actuators: sensors take in information, actuators do something.
- Driving a motor straight from a microcontroller pin. It needs a transistor or driver.
- Forgetting the loop: a check done once at start-up will never react later.