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

  • 1
    Please post your code here. We don't have crystal balls here :)
    – Gerben
    Dec 14 '14 at 16:51
  • 1
    And a wiring diagram or schematic, since this is hardware-based as well. Dec 14 '14 at 17:09

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
    Dec 15 '14 at 5:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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