i am tring to enter a series of numbers using "keypad" to different variables..when simulate the code on proteus it only took the first "getkey()" function and ignored the rest .. SO, How can i block an arduino code until a key is pressed by keypad, in other words prevent the rest of code from being executed before a key is pressed
-
1Please post your code here. We don't have crystal balls here :)Gerben– Gerben2014年12月14日 16:51:09 +00:00Commented Dec 14, 2014 at 16:51
-
1And a wiring diagram or schematic, since this is hardware-based as well.Ignacio Vazquez-Abrams– Ignacio Vazquez-Abrams2014年12月14日 17:09:58 +00:00Commented Dec 14, 2014 at 17:09
1 Answer 1
It depends on how the "keypad" is implemented. If you've got it hooked up to a hardware interrupt, then you only need to add an interrupt handler for that event.
On the other hand, the more "straight-forward" implementation is that you have to poll the pins to see if a key was pressed. Simply do that in a loop until you see a key press, call your event-handler method, and then continue to loop.
-
thanks a lot, I used waitForKey() function from keypad library and it worked correctly :)A.M.H– A.M.H2014年12月15日 05:25:06 +00:00Commented Dec 15, 2014 at 5:25