Vending machines, traffic lights, text-search engines and the lexers inside every compiler are finite automata: machines with a fixed, finite memory that react to one input symbol at a time. They are the simplest model of computation, and the starting point for asking what more powerful machines can do.
We will follow states and transitions and finish with the memory in the state.
Step 1: States and transitions
A deterministic finite automaton (DFA) has finitely many states and a fixed transition rule: from each state, each symbol leads to exactly one next state. Run it by starting in the start state and applying the transition for each symbol in turn; it accepts if it ends in an accepting state. Example: a DFA with states A and B, where a keeps the state and b switches it, tracks whether it has read an even or odd number of bs. On abba it goes A, A, B, A, A: the state changes twice, and it ends in A.
Step 2: Memory in the state
A DFA's only memory is its current state, so designing one means deciding what to remember. To check divisibility of a binary number by 3, remember the value mod 3 read so far: reading bit b doubles the value and adds b, so
The three states are the possible remainders. Reading 1011 (eleven) visits 0 → 1 → 2 → 2 → 2, and 11 mod 3 = 2. The same idea works for any modulus: tracking mod 5, from state 2 the bit 1 leads to (4 + 1) mod 5 = 0.