I am trying to implement a button widget that can detect multiple clicks rather than a long hold and release and then get a particle photon to act upon that.
I’ve spent the evening searching the forum and haven’t been able to come up with a solution. I’ve seen a few examples on here of a long hold using timers and will use that approach if I can’t achieve my first goal.
Can anyone point me in the right direction please.
I might be off on some syntax, if you want to collect the amount of presses and have code act upon it
I would do something like this.
This will be a bit stressful perhaps so adjust your fireDelay down here
int presses = 0; // tracks presses
int fireDelay = 1; // execute after 1 second from first presses
boolean fireEvent = false; // check flag
SimpleTimer timer; // timer for firing event
BLYNK_WRITE(V0)
{
presses++;
// Check flag is to prevent multiple fires
if (!fireEvent)
{
fireEvent = true;
timer.setTimeout(fireDelay * 1000L, doFunction());
}
}
void doFunction()
{
//doStuffHere
//use 'presses' variable for number of presses
presses = 0;
fireEvent = false;
}