Execute while a button is pressed

Why does @simonmclennan need to know that?

Ok, it's less simple that not debouncing the buttons.

Adding to the dogpile with a strawman...

  • scan all buttons (released is HIGH, pressed is LOW)
  • detect first syllable of a button press (any LOW)
  • start task associated with the button
  • ignore/skip this button during buttons-scan for a known period
  • detect first syllable of button release (any HIGH)
  • end task associated with the button

output from code in post #12 with buttons held down with 500msec Tmout

11:33:27.784 -> LhTopLimit--
11:33:27.784 ->     -1
11:33:28.300 -> LhTopLimit--
11:33:28.300 ->     -2
11:33:28.785 -> LhTopLimit--
11:33:28.785 ->     -3
11:33:29.316 -> LhTopLimit--
11:33:29.316 ->     -4
11:33:29.779 -> LhTopLimit--
11:33:29.779 ->     -5
11:33:30.309 -> LhTopLimit--
11:33:30.309 ->     -6
11:33:31.309 -> LED-13
11:33:31.785 -> LED-13
11:33:32.306 -> LED-13
11:33:32.782 -> LED-13

If the led is just an indicator that the button is pushed, there is no need for an arduino…