Skip to content

About

Arduino State Machine experiments

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

141 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StateMachine

Arduino State Machine experiments

I have made this repository which was not at first visible in my GitHub as it is private and I needed to log in.

I have now made this repository public.

State Machine diagrams

I have begun to use Mermaid (https://mermaid.js.org/intro/getting-started.html) as a way of making diagrams for Finite State Machines.

Mermaid can be used to make a range of different diagrams and they can be coded as special text in GitHub pages using Markdown.

stateDiagram-v2
  state: "Door"
  open --> closed : Closing
  closed --> open : Opening
Loading

There needs to be some other text between diagrams.

Another diagram

  stateDiagram-v2
  direction LR
  state: "Door"
  open --> closed : Closing
  closed --> open : Opening
Loading

Diagram with locking added

 stateDiagram-v2
 direction LR
 state: "Door"
 open --> closed : Closing
 closed --> open : Opening
 closed --> locked : Locking
 locked --> closed : Unlocking
Loading

Diagram with locking added and some forbidden actions

 stateDiagram-v2
 direction LR
 state: "Door"
 open --> closed : Closing
 open --> locked : XX Cannot lock
 closed --> open : Opening
 closed --> locked : Locking
 locked --> closed : Unlocking
 locked --> open :  XX Cannot open
Loading

Diagram with closed and unlocked as the same thing:

 stateDiagram-v2
 direction LR
 state: "Door"
 open --> closed_unlocked : Closing
 closed_unlocked --> open : Opening
 closed_unlocked --> locked : Locking
 locked --> closed_unlocked : Unlocking
Loading

Diagram with closed and unlocked as the same thing:

 stateDiagram-v2
 direction LR
 state: "Door"
 open_unlocked --> closed_unlocked : Closing
 closed_unlocked --> open_unlocked : Opening
 closed_unlocked --> closed_locked : Locking
 closed_locked --> closed_unlocked : Unlocking
Loading

Diagram with heirarchy

   stateDiagram-v2
   direction LR
   state: "Door Closed"
   [*] --> A : want to lock
   state A {
   [*] --> Unlocked
   Unlocked --> Locked : Locking
   Locked --> Unlocked : Unlocking
   Unlocked --> [*]
   }
   [*] --> B : want to open
   state B {
   [*] --> Closed
   Closed --> Open : Opening
   Open --> Closed : Closing
   Closed --> [*]
   }
Loading

Embedded Template Library

I am putting my examples for the Embedded Template Library Arduino library into a folder here.

Other codes

Some of these codes use the StateMachine library and some have been changed to use TaskManagerIO instead.

arduino_state_test

Empty base case

arduino_state_machine

Example with serial monitor output

arduino_state_blink

This is the first example to blink the LED.

arduino_state_blink_new

Example using enum class instead of enum.

arduino_state_blink_moustache

This is a new example which replaces the previous output using the Arduino moustache for output.

This shows how a format can be defined for the output of the description of a state which will then output one of an array of state descriptions.

This has now been extended to allow for run time values and also error reporting.

The extensions have now been moved to the moustache library.

states_timers

Timers example from the StateMachine library.

About

Arduino State Machine experiments

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages