jonblack / arduino-fsm

Arduino library for implementing a finite state machine.
MIT License
200 stars 97 forks source link

Add timing to state transitions #1

Closed jonblack closed 9 years ago

jonblack commented 9 years ago

A comment on my blog asked about using multiple FSM's to simulate multi-tasking. This is a nice idea, but the FSM cannot control the timing in its current state.

For example, if you want a servo to spin for 3 seconds and during the same period have an LED blink 6 times, the client needs to keep track of the time. In a large sketch with a lot of multi-tasking, this would be cumbersome.

A possible solution is to add a function called add_timed_transition which takes a parameter stating how long the FSM stays in the given state before automatically transitioning to another.

jonblack commented 9 years ago

Implemented and in master.