I am having difficulty with my security panel project. I'm getting a error saying that 'setLocked' was not declared in the scope. I don't know what my next step should be. There was a topic on this same thing and i read it but i'm still confused on what's wrong and jut can't figure it out. please help.
#include <LiquidCrystal.h>
#include <Keypad.h>
int RED = 10;
int GREEN = 11;
char* password = "1234";
int posit = 0;
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};
Keypad myKeypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
const int rs = 0, en = 1, d4 = 2, d5 = 3, d6 = 4, d7 = 5;
LiquidCrystal lcd (rs, en, d4, d5, d6, d7);
void setup() {
lcd.begin(16, 2);
pinMode(RED, OUTPUT);
pinMode(GREEN, OUTPUT);
setLocked(true);
}
void loop() {
char whichKey = myKeypad.getKey();
lcd.setCursor(2, 0);
lcd.print("Good Evening");
lcd.setCursor(5, 1);
lcd.print("Master");
delay(2000);
lcd.clear();
delay(1000);
lcd.setCursor(1, 0);
lcd.print("Please enter");
lcd.setCursor(1, 1);
lcd.print("your PW:");
lcd.blink();
if (whichKey == '*' || whichKey == '#' || whichKey == 'A' || whichKey == 'B' || whichKey == 'C' || whichKey == 'D') {
posit = 0;
setLocked (true);
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("Invalid key!");
delay(1000);
lcd.clear();
}
if (whichKey == password[posit]) {
posit ++;
}
if (posit == 4) {
setLocked(false);
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("***Verified***");
delay(3000);
lcd.clear();
delay(1000);
}
void setLocked(int locked) {
if (locked) {
digitalWrite(RED, HIGH);
digitalWrite(GREEN, LOW);
}
else {
digitalWrite(RED, HIGH);
digitalWrite(GREEN, LOW);
}
}
}