I am new to Arduino and I assume this is a simple programming mistake, but I can't figure it out or find the solution anywhere else. I get an error "expected primary-expression before 'getState'". Thanks in advance. ![]()
#include <Keypad.h>
#include <LiquidCrystal.h>
const byte ROWS = 4;
const byte COLS = 3;
char hexaKeys[ROWS][COLS] = {
{'#', '0', '*'},
{'9', '8', '7'},
{'6', '5', '4'},
{'3', '2', '1'}
};
byte rowPins[ROWS] = {13, 12, 11, 10};
byte colPins[COLS] = {9, 8, 7};
Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
const int rs = 1, en = 2, d4 = 3, d5 = 4, d6 = 5, d7 = 6;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
int passchars = 0;
int pass;
char one;
char two;
char three;
char four;
void setup() {
lcd.begin(16, 2);
lcd.print("Enter Password:");
}
void loop() {
lcd.setCursor(0,1);
if(KeyState getState() == PRESSED){ //error on this line
if(char getKey() == '#'){
pass = null;
passchars = 0;
}
else{
passchars++;
if(passchars==0){
one = char getKey();
}
if(passchars==1){
two = char getKey();
}
if(passchars==2){
three = char getKey();
}
if(passchars==3){
four = char getKey();
}
}
//Checks if four characters have been entered.
if(passchars==3){
}
}
}