dear community,

i have tried to do the following:

i have added a button for the digital input.

i have also added a led for the output.

currently if i press on my board the button, the led goes on until i stay on the button.

now i have added a counter. i see now how much i have pressed the button.

i need to find out the time between the last and current presses.

i have tried it with

int timeA = 0;

int timeNeeded = 0;

here on my loop:

if(timeA==0)

{

timeA = millis();

}

if(timeNeeded==0)

{

timeNeeded = timeA-millis();

}

// here i doe a output to a display

// print -> timeNeeded

timeNeeded = 0;

timeA=0;

so now i think it should work, but i dont know...

for the first 10-20 presses, the time is correct.

then the time is not correct (between the presses).

can anybody tell me how i can do this?

in this case:

if i press on 00:00:00 the button and the next i press on 00:00:05,

then i need the "last time taken" 5000 millis.

if i press on 00:00:00 the button and the next i press on 00:00:12,

then i need the "last time taken" 12000 millis.

need this for calculation for the following.

if i press now all 10 seconds the button, then i must calculate this / 8.

in this case i get 1,25 per cycle.

now the led should blink 8 times in this time. and then if the next push is there,

the script should auto calculate the next 8 cycle (from the readed "last time taken").

can anybody helps me how i can do this on the best way?

thank you very much,

many greets