1

I am making a program in which i have an infinite loop. I used kbhit() to detect whether a key is pressed or not. I am also using delay in the loop. So the problem is if i press the key i have to wait for the time given in delay function to perform kbhit() function actions.....

while(1)
{
delay(1000);
if(kbhit()) 
{
//
//
//
//
}
}

//now i have to wait 1000ms to execute kbhit()'s code how to remove this problem..

Thanks in advance....

Linkin
  • 11
  • 2

1 Answers1

0

Please improve your way of asking! Anyway I'll try to help you: It seems you want to use interrupts.

But in the most cases it's actually enough, to check keyboard inputs at a certain rate. E.g. a game that runs with 60FPS won't need more than 60 checks per second. You may explain for what you need this way of keyhandling.

Peter Wildemann
  • 465
  • 4
  • 13