Measure Total Time a Push Button Is Set To HIGH and when Desired Time Is Reached

Hello Everyone,

Fairly new to C# and Arduino programming here...

Ill try and make this quick, so my question is i need to program my nano to (As the subject says):

Measure Total Time a Push Button Is Set To HIGH and when Desired Time Is Reached turn on a LED...

To clarify, i want the nano to measure the time a push button attached to digital pin 4 is read HIGH (push button not pressed is LOW) and i need to be able to make multiple presses on the button and have the total time saved and accrued (added) each time it goes HIGH, and when a total of 10 seconds of time is measured of the button being HIGH, a LED on Digital pin 5 turns on.

so for example if i push the button for 2 seconds the nano will save the total time of 2 seconds and wait for me to press it again, now when i press the button for 6 seconds the program will add 2 + 6 = 8 and when if my next move of pressing the button again for 3 seconds the program will limit my press to 2 seconds because 8 + 2 = 10 and will then turn on the LED and do nothing if the button is pressed again...

hope this is clear enough... i dont have any code yet to post but if anyone could help me out with something to start with, i would greatly appreciate it.

thanks
MrGmo

Sounds like a stopwatch.

Something like this - but it may be doing the opposite of what you want, if so just change the HIGH to a LOW

buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {          // assumes LOW when pressed
   lastTimeButtonWasNotPressed = millis();
}

if (millis() - lastTimeButtonWasNotPressed >= interval) {
   // button has not been pressed during the interval
   // do stuff
}