Hey guys, having a problem with my project. i have a keypad from seeedstudio. (12 key, 13 pin individual pins for each key).
i got the project working with a really long if statement but im trying to clean up my code and possibly get the keypad readings using a couple of arrays to read which button is pressed...
problem is that i can't get it to read which button and my lcd screen only shows "#" constantly.
my code is as follows:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
String button;
String Keys[12] = {"1","2","3",
"4","5","6",
"7","8","9",
"0","*","#"};
int Pins[12] ={A3,1,5,
A2,0,4,
A1,A5,3,
A4,A0,2};
void setup() {
lcd.begin(16,2);
pinMode(A0, INPUT_PULLUP);
pinMode(A1, INPUT_PULLUP);
pinMode(A2, INPUT_PULLUP);
pinMode(A3, INPUT_PULLUP);
pinMode(A4, INPUT_PULLUP);
pinMode(A5, INPUT_PULLUP);
pinMode(0, INPUT_PULLUP);
pinMode(1, INPUT_PULLUP);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(4, INPUT_PULLUP);
pinMode(5, INPUT_PULLUP);
}
void loop() {
delay(1000);
lcd.setCursor(0,0);
lcd.print(GetKey());
}
String GetKey(){
for(int i=0; i<13; i++){
if(digitalRead(Pins[i] == LOW)){
button = Keys[i];
}
}
return button;
}