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?
-
2\$\begingroup\$ could you post your code. What have you tried so far? \$\endgroup\$– danial weaberJul 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\$– MayankJul 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\$– MayankJul 23, 2017 at 10:50
1 Answer
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.