awake 0.2 mAasleep 0.1 µATMP36MCUATmega328Pflash 32 KBSRAM 2 KBz z16 MHzpin 81void loop() {2 int t = readTemp();3 digitalWrite(HEAT, t < 20);4 delay(1000);5}thermostatwashercarwatch141146182110
Back: the board inside a thermostat (microcontroller, clock, battery, sensor, heater)Front: the firmware card and everyday devices that hide such a computerTokens: the program, sensor readings, on/off signals and clock ticksThe inside of a room thermostat: a microcontroller (ATmega328P) with its flash and SRAM, a 16 MHz clock, a battery, a temperature sensor and a heater, and the firmware's loop() on a card in front. Each second the firmware senses (141 becomes 18 degrees in SRAM), decides (18 < 20) and acts (pin 8 HIGH, heater on), then does it again. The limits: 32 KB of flash, 2 KB of SRAM, a 16 MHz clock and a battery's energy.

Where they live

  1. An embedded system is a computer built into a device to do one job. Thermostats, washing machines, cars and watches all have one. You never see it or install apps on it: it just runs the device.

One job, forever

What limits them

What happens

;; step 1/10 · everywhere
embedded system  a computer hidden inside a device,
                 built for one dedicated job
  thermostat
  washer
  car
  watch
no screen of apps, no keyboard: it just runs the device

The card shows only loop(). The whole sketch also defines HEAT = 8, sets the pin as an output in setup(), and defines readTemp(), which turns the ADC number into degrees with whole-number maths (so 141 becomes 18, not 18.8). The current figures are the headline numbers of the commercial ATmega328P datasheet (DS40002061B): active and power-down mode at 1 MHz, 1.8 V and 25 °C. At 5 V and 16 MHz the chip draws more, and an Uno board also powers its USB chip, regulator and LED.