Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // read from keypad to array
- // in this code working
- // but when I use for loop it's not working properly the Key can enter to the same array several pressing.
- #include <AnalogMatrixKeypad.h>
- #define analogPin 0
- AnalogMatrixKeypad AnMatrixKeypad(analogPin);
- char Key,attempt[2];
- int i=0;
- void setup()
- {
- Serial.begin(9600);
- }
- void loop()
- {
- Key = AnMatrixKeypad.readKey();
- if (Key != KEY_NOT_PRESSED)
- {
- attempt[i]=Key;
- Serial.println(attempt[i]);
- i++;
- }
- if(i==2)
- i=0;
- }
- -----------------------------------------------------------
- //for loop not working properly
- for(i=0; i<2; i++)
- {
- Key = AnMatrixKeypad.readKey();
- if (Key != KEY_NOT_PRESSED)
- {
- attempt[i]=Key;
- Serial.print("The Key ");
- Serial.println(attempt[i]);
- Serial.print("enter to the array ");
- Serial.println(i);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement