The place where random ideas get written down and lost in time.
2022-05-10 - Arduino Sequence Controller?
Category DEVI’ve been thinking about how Lacan uses his Arduino for his aircraft animation.
What he needs is really a sequence controller to create time-base sequences triggered by input events.
If I had to program this from scratch, what would I do? I’d create a “mini language” using either macro or C++ objects which represents states to change over time:
- LED timings is really just a list of (start timestamp, LED pin, LED state).
- Servos: (start timestamp, servo pin, angle to reach, speed or duration)
- Motors: (start timestamp, motor pin, power level, direction)
- Instructions to end sequence, repeat N times, or chain to another sequence.
Depending on the specific needs:
- Sequence(s) are started by an input (with either forced restart or don’t retrigger).
- Need more than one concurrent sequence? Make each sequence independent. That is each sequence is started and actuates by itself on main clock.
- Need to make sequences run solo? Have an instruction that stop/cancel all other sequences.
- Maybe put sequences in groups (e.g. “servo groups”, “lights groups”) and make the group exclusive as in only 1 sequence runs in the group, or be able to stop any running sequence in the group.
For example for the case of the variable geometry plane:
- IR button 1 ⇒ sequence 1 = stop sequence 2, move servo N up to 60. No retrigger.
- IR button 2 ⇒ sequence 2 = stop sequence 1, move servo N down to 0. No retrigger.
- IR button N ⇒ sequence N for lights.
It seems so obvious that I would be surprised if this had not been done before and be made available as a customizable library for arduino.
For model trains, there are a couple obvious usages:
- Sequencing road traffic lights, e.g. to animate a city.
- With the addition of a “random LED value” instruction, animate anything from a camp fire to a building in fire.
Generated on 2025-01-18 by Rig4j 0.1-Exp-f2c0035