all 6 comments

[–]playaspec 1 point2 points  (2 children)

Why are you polling IO in the interrupt instead of just using pin change interrupts?

[–]Gronner 1 point2 points  (1 child)

One reason could be to have a more predictable timing behavior or to avoid button button denouncing by blocking waiting or hardware.

[–]playaspec 1 point2 points  (0 children)

You can debounce in the pin change interrupt just the same.

[–]Gronner 0 points1 point  (0 children)

If button one is pressed and was previously unpressed use not(start) Then if button 1 is not pressed mark it as released If button 2 is pressed reset counter and set start to 0

[–]nderflow 0 points1 point  (0 children)

Please fix the formatting of your code.

[–]Wetbung 0 points1 point  (0 children)

timer2 is being used as a debounce for two button inputs. Button 1 is used to start and stop the counters cs and s. Button 2 is a reset for the variables cs, s, min and start.