Hi.
Is there a way to check if a key is pressed while in setup function?
I'm using a 4*4 keypad.
Using if keypressed didn't work, so i tried to read the state of pins used for the keypad (so if a state is HIGH i can say a key is pressed).
When checking the states with digitalRead(), i get 1,1,1 and 1 for rows and fluctuating values of columns (i can get 0,0,0,0 ; 0,1,1,0; or even 1,1,1,1 without pressinng any key).
So i can't see how can i check if a keypad is pressed while in setup function.
When you call getKey(), it determines if any key is pressed AT THAT INSTANCE. It does NOT wait for a key to be pressed. Are you expecting that it will?
You'll have to post your code for us to help. We need to see it to make sure that you have set things up correctly.
Click on the </> button above the edit window and paste your code in the block.
My code is a little bit big. The keypad is is working fine whith every thing in loop function
PaulS:
When you call getKey(), it determines if any key is pressed AT THAT INSTANCE. It does NOT wait for a key to be pressed. Are you expecting that it will?
That's why i tied to check if a column digital pin is HIGH (=keypressed in that column) at that exact moment (so if you are pressing while the program checks, it will read a HIGH value),but as mentioned before, i didn't get a constant LOW value if all keys are not pressed. Maybe that's related to the keypad library.
Thanks for the suggestion, ut waitForKey() method stops everything until a key is pressed, i just need to change some variales values if key is pressed and work with default values if not.