I want to be able to select different options in my loop. I could use i.e. a few digital or analogue inputs and use if, else, switch, etc.
But my idea is to do this with just one button and commands like morse code.
If I press Long, short, short A happens
If I press Long, Long, Long B happens
And some more options.
Currently I use no wait and I run a timer every 10 ms. I could change this to another ms value or use a different timer. My loop time does not have to be precise. +/- 10% is no problem.
#include <MsTimer2.h>
void setup() {
MsTimer2::set(10, timedLoop);
MsTimer2::start();
}
void timedLoop(){
//work
}
I guess I could monitor for how long a button is pressed. And then look for a pattern like "long, short, short" and other options.
But before I try to do that from scratch I thought I ask the community if there is some public code for this or maybe a library.
There is no point to "invent" this again if others did it already.
Any ideas?
Thanks