In this series, I show how to replicate, visualize, and expand basic digital circuits using modern microcontroller technology. The goal is to make classic digital logic (AND, OR, NOT, flip-flops, clock generators, etc.) understandable using Arduino as a transparent experimentation tool.
Why does this project exist?Many beginners learn Arduino only through ready-made sample codes. The basics of digital logic are often lost in the process. At the same time, classic digital technology kits seem old-fashioned or expensive.
That's why I combine both: basic digital circuits + Arduino + visualization.
This allows learners to understand what is really happening.
What am I doing?I recreate a digital function in each part and explain:
- how the logic behind it works
- how to test it with simple Arduino examples
- how to make signals visible (LEDs, serial plotter, oscilloscope simulation)
Let's start.
1. IntroductionFinite state machines can be divided into two basic types:
• Moore machine
• Mealy machine
The difference is conceptually simple—but significant.
2. Moore machineA Moore automaton, named after mathematician Edward Forrest Moore, is a finite automaton with output. In a Moore automaton, the outputs depend exclusively on the current state.
Features:
• Clear, stable outputs
• Easy to debug
• Often requires slightly more states
Conceptual model: State → Output
Example:
- LED on/ off
switch (state) {
case IDLE:
digitalWrite(LED, LOW);
break;
case ACTIVE:
digitalWrite(LED, HIGH);
break;
}To illustrate the Moore automaton more clearly, let's take the familiar example of a traffic light.
We need four states for this, one for each traffic light phase. Green is state Z0, our start state. Yellow gets state Z1, yellow-red Z2, and finally red Z3. This allows us to create the automaton table.
First, we can enter the outputs that are to be issued when the respective states are reached into the Table 1. To achieve this, we use the binary coding shown in Figure 1, for example 001 for the colour green.
Next, we define our state transitions. When a traffic light is green (Z0), it can either remain green (0, Z0) or change to yellow (1, Z1). If it is yellow (Z1), it then changes to red (Z3). It remains there for a while and then switches to yellow-red (Z2) and then back to green (Z0). The table on the right lists all states and transitions.
As a state transition diagram, the whole thing then looks like Figure 2.
You can see that in the individual states, the output is also modelled (green area for green traffic light, etc.).
A Mealy machine, named after mathematician George Mealy, is a finite state machine that also has outputs. Unlike Moore machines, the outputs of Mealy machines depend on the current state and the inputs.
Features:
- Often fewer states
- Reacts faster
- More difficult to debug
Conceptual model: State + input → output
Example:
- Key press evaluation
if (state == ACTIVE && buttonPressed()) {
digitalWrite(LED, HIGH);
}To better understand Mealy machines and how they differ from Moore machines, let's take another look at the traffic light example.
With Mealy, the output depends on the input and the current state. In our example, the input is the elapsed time. This means that the traffic light phases are no longer determined solely by the state, but also by the time condition. Therefore, the number of states is reduced to one in this case.
The state does not change. The behaviour changes continuously. Each loop() run decides anew:
- What time is it right now?
- Which outputs need to be set?
⚠️ All outputs are linked to conditions, not states, for this:
- more difficult to read
- Less expandable
- More difficult to debug
- The system is constantly thinking instead of following a stable state
For more information, please visit my Blog:








Comments