Created
December 15, 2013 19:56
-
-
Save keshavsaharia/7977356 to your computer and use it in GitHub Desktop.
4x4 keypad matrix for Arduino
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int getKey() { | |
int A = 2; | |
while (A <= 5) { | |
pinMode(A, OUTPUT); | |
digitalWrite(A, HIGH); | |
int B = 6; | |
while (B <= 9) { | |
pinMode(B, OUTPUT); | |
pinMode(B, INPUT); | |
if (digitalRead(B) == HIGH) { | |
return (A - 2) * 4 + (B - 5); | |
} | |
} | |
digitalWrite(A, LOW); | |
A = A + 1; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment