This is a somewhat general Arduino programming question with a specific project context. I'm quite comfortable with OO languages like Processing/Java, but I'm not quite as well-rounded with C/C++ programming and don't quite know how to tackle this (probably) simple question.
Let's say we have a button and a motor: the user presses a button and the motor goes on/off in several short pulses, then stops. This could be done very easily with delay() or, with a bit more code, using millis(). That's pretty easy but when one adds several buttons and several pulsing motors, the code gets messy very quickly. I'd especially like to be able to create different pulsing patterns (long, short, long, long, etc) which could be stored in an array - which makes using multiple instances of millis() even messier.
I'm curious if there's a cleaner and more re-usable way to handle this kind of thing? Ideally, a button would be pressed, the sequence of pulses would be triggered, but the pulse timing and ending code would be handled in some kind of function.