# Wanted: Simple state machine examples

**URL:** <https://discourse.nodered.org/t/wanted-simple-state-machine-examples/97482>\
**Category:** General\
**Created:** [8 June 2025 14:00 UTC](https://discourse.nodered.org/t/wanted-simple-state-machine-examples/97482 "2025-06-08T14:00:55Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [8 June 2025 15:08 UTC](https://discourse.nodered.org/t/wanted-simple-state-machine-examples/97482/5 "2025-06-08T15:08:11Z")

</div>

Try these links... for ideas...

> [@Finite State Machine (FSM) - UK traffic lights](https://discourse.nodered.org/t/finite-state-machine-fsm-uk-traffic-lights/1580):
>
> [UK traffic lights and FSM](http://resources-area.co.uk/node-red-flows/traffic_lights_and_fsm.pdf) The above link will take you to a tutorial about Finite State Machines (FSM). The model is based on the UK traffic light sequence. Here's a link to the Node-RED flow. [Node-RED flow](http://resources-area.co.uk/node-red-flows/fsm_traffic_lights.txt) Trust you enjoy reading the tutorial.

> [@Finite State Machine (FSM) with delay](https://discourse.nodered.org/t/finite-state-machine-fsm-with-delay/88275):
>
> I was asked the other day about how to create a Finite State Machine (FSM) with different delays between various transitions. Here is a simple example, based on the UK traffic light sequence, that makes use of the msg.delay option in the Delay node. Here's a screenshot of the flow. [{"id":"be3ab1ef.3f0a68","type":"tab","label":"Traffic Lights with variable delay","disabled":false,"info":"","env":[]},{"id":"743e732.c12228c","type":"function","z":"be3ab1ef.3f0a68","name":"Decode…

> [@Garage Door - revisited](https://discourse.nodered.org/t/garage-door-revisited/93404):
>
> I posted this project way back in November 2021, so 4-years old now. This is a photo of the original project installed on my garage wall... This week I took another look at the project with a view to bringing it up-to-date. These are the changes I've implemented... Re-written the code using Micro-Python Removed the ESP-01S and re-routed D4 to drive the transistor that drives the relay Swapped the Wemos D1 Mini for an ESP32-S2-Mini (faster processor and more PSRAM) E…

> [@Is anyone here interested in Train Signals and how they work?](https://discourse.nodered.org/t/is-anyone-here-interested-in-train-signals-and-how-they-work/19759/24):
>
> Got a bit bored this afternoon so I knocked-up this demo flow. It has a finite state machine (FSM) for each of the 6 signals and an animated slider to mimic a train journey. To keep things simple there is only one buffer block (caution block) - you can obviously modify that by introducing additional blocks and signals. BOD means Block Occupancy Detector. Hope you find it useful. The Node-RED flow is below as together with the screenshots it …

> [@Orange (or Raspberry) Pi Controller](https://discourse.nodered.org/t/orange-or-raspberry-pi-controller/96456):
>
> This tutorial documents the steps to build a controller that will boot-up / shut-down an Orange Pi or Raspberry Pi in a graceful way so as to minimise the risk of losing data or corrupting files. I recently purchased an Orange Pi 5 Pro with a 64GB eMMC and a 512GB NVMe SSD, then installed OpenMediaVault (OMV) on it to serve as a small Network-Attached Storage (NAS) device on my home network. Although OMV provides a web-based user interface for managing the NAS and shutting it down in a controll…

You can code an FSM using 'case' constructs in pure JavaScript.

There are also a number of Node-RED Nodes that implement FSMs...  
(I've not used them as I code mine in JS), here is just one as an example...  
Do a search for FSM in the flows library tab - you'll find countless nodes.

> **[node-red-contrib-dsm](https://flows.nodered.org/node/node-red-contrib-dsm)**
>
> A dynamic state machine node based on the finite state machine model.

Finally, here's a link to a tutorial on FSMs I wrote for my IoT students a few years ago...

> **[traffic\_lights\_and\_fsm.pdf](https://resources-area.co.uk/node-red-flows/traffic_lights_and_fsm.pdf)**
>
> 467.14 KB

---

_[View the full topic](https://discourse.nodered.org/t/wanted-simple-state-machine-examples/97482)._
