This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
In main code as in continuous polling? I added the delay but I am also running a 4 digit seven segment display and reading analog signals and it stops while the delay function is running and it is visible enough to cause problems? Is there any solution for this?
Hi SURESHAN,
Keith is correct. A simple way is that you can add a delay in the "if(...){;}" and then check the input again, if it still got the same value, then it is a valid input.
However, it is quite common requirments in button detection, you can search it in the Internet, there should be some workable solutions that you can refer to.
B.R.
Sal
You need to use a timer to set up a non-blocking delay. I use SysTick to set up an Arduino-like "Millis" function. Then when I see a button press, I store the starttime of the press. After a certain amount of time has past (15 ms or so for my Cherry buttons) , I then register the button press.
something like this in pseduocode:
if (button1pressed)
then
if (button1start == 0)
then
button1start = Millis(); if button1start == 0 then button1start = 1; // In case Millis happens to be 0!
else
if (Millis() - button1start > 15)
then register keypress
endif
endif