0
\$\begingroup\$

I have a small project where I set up a timer interrupt to check the state of few buttons. Do I need to set up 1 timer per button or can I check 2 or 3 with 1 timer?

\$\endgroup\$
3
  • 2
    \$\begingroup\$ could you post your code. What have you tried so far? \$\endgroup\$ Jul 23, 2017 at 6:15
  • 1
    \$\begingroup\$ you can check as many numbers of buttons as the timer interrupt frequency allows. But I believe you are missing to add more details to question. It's too vague! Is this code only for learning purpose or for some product? \$\endgroup\$
    – Mayank
    Jul 23, 2017 at 10:48
  • \$\begingroup\$ Is there any other task that you want to execute when not checking for button states? Or you are simply waiting for some time period? \$\endgroup\$
    – Mayank
    Jul 23, 2017 at 10:50

1 Answer 1

1
\$\begingroup\$

You can use systick timer and a function(s) that at each systick interrupt increments a variable and compares with set time. Then it outputs a state.

Also you could make array of timers, that are processed at each systick interrupt.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.