Exit status 1 'KeypadProcess' was not declared in this scope

When i try to upload this to my arduino it comes up with the error message in the title of this topic

#include <Keypad.h>
#include <LiquidCrystal.h>


int Timer1 = 10000;
int Timer2 = 20;
int Timer3 = 10;
//LCD set up
LiquidCrystal lcd(A0, A1, A2, A3, A4, A5); //RS, RW, D4, D5, D6, D7 PINS on lcd
bool LCDstartup = true;

//state selection
enum SystemStates {Engaged, Disengaged};
SystemStates AlarmState = Disengaged;
short armedTimerInterval = 8;
unsigned long armedTimer = millis();

// Led's
int LEDr = 12; //Red Led on pin 9
int LEDg = 45; //Led on pin 18

//Alarm siren
int Alarm = 11;
bool AlarmActivation = false; 

//PIR
int PIR = 47;
int PIRValue;

//assigning buzzer
int Buzzer = 10;

// Assigning detection pins, window and 2 doors
int Window = 49;
int WindowContact;

//Password
char Password;
char accessCode[] = "1346";                                      //disarm code
char keyPadInput[] = "zzzz";

//Defining keypad
const byte ROWS = 4;
const byte COLS = 4;

char hexaKeys[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 CODE = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);

//password
void setup()

{
    lcd.clear();
    lcd.begin(16,2);
    pinMode (LEDr,OUTPUT);
    pinMode (LEDg,OUTPUT);
    pinMode (Alarm,OUTPUT);
    pinMode (PIR,INPUT);
    pinMode (Buzzer,OUTPUT);
    pinMode(Window,INPUT);
    Serial.begin(9600);
  while (!Serial); // wait for Serial to connect
  Serial.println("ready");
}
void loop(){
  LCDstartupProcess();
  KeypadProcess();
  PIRProcess();
  AlarmProcess();
 WindowProcess();
}
const char* getStateString(enum SystemStates)
{
  switch (SystemStates)
  {
    case Engaged: return "Engaged";
    case Disengaged: return "Disengaged";
  }
}
// LCD Startup Process
   void LCDstartupProcess() {
  if (doLCDstartupProcess) {

    LCDstartupProcess = false;
    lcd.clear();
  } 
    String a = getStateString(SystemStates);

    if (debug) {
      Serial.println("AlarmState: " + a);
    }

    lcd.setCursor(0, 0);
    lcd.print(a);
    lcd.setCursor(0, 1);
    lcd.print("Press Engage key.");
  }
}

void handleLCD(bool LCDisClear) {
  if (LCDisClear) {
    lcd.clear();
  }

  String a = getStateString(AlarmState);

  if (debug) {
    Serial.println("SystemState: " + a);
  }

  lcd.setCursor(0, 0);
  lcd.print(a);
  lcd.setCursor(0, 1);


  lcd.print("Disengage Key:");
  uint8_t cursorStart = 11;
  lcd.setCursor(cursorStart, 1);
  lcd.cursor();


  for (int i = 0; i < 4; i++) {
    if (keyPadInput[i] == 'z') {
      lcd.setCursor(cursorStart + i, 1);
      lcd.print(" ");
    } 
    
    else {
      lcd.setCursor(cursorStart + i, 1);
      lcd.print(keyPadInput[i]);
    }
  }
}




//keypadProcess
void KeypadProcess() {
  Password = CODE.getKey();
  if (Password) {

    Serial.print("Password: ");
    Serial.println(Password);

    if (SystemStates == Disengaged) 
    {
      if (Password == '*') {
        BuzzerProcess();
        SystemStates = Engaged;
        LCDstartupProcess(true);
      }
    }
    else 
    {
      if (Password == '*') {
        resetCodeInput();
      } else if (Password == '#') {
        if (strcmp(keyPadInput, accessCode) == 0 ) {
          Serial.println("Access Granted");
      
          resetCodeInput();
          SystemStates = Disengaged;
          doLCDstartupProcess = true;
          LCDstartupProcess();
        } else {
          resetCodeInput();
        }
      } else {
        if (inputCounter <= 3) {
          keyPadInput[inputCounter] = Password;
          inputCounter++;
          LCDstartupProcess(true);
        } else {
        
        }
      }
    }
  }
}
//BuzzerProcess
void BuzzerProcess (){
  tone(Buzzer, 100);
  delay(timer);
  noTone(Buzzer;
}
//Reset
void resetCodeInput() {
  Serial.println("reseting keyPadInput");
  for (int i = 0; i < 4; i++) {
    keyPadInput[i] = 'z';
  }
  inputCounter = 0;
  handleLCD(true);
}
//PIRProcess
void PIRProcess() {
  pirValue = digitalRead(PIR);
}
//AlarmProcess
void AlarmProcess () {
  if (pirValue > 0 && armedState == ARMED ) {
    Alarming = true;
  } else {
    Alarming= false;
  }

  if (Alarming) {
    Serial.println("Alarming");
    lcd.setCursor(2, 0)
    lcd.print("Alerting Police");
  }

  LEDProcess();

  BuzzerProcess();

}
//LEDProcess
void LEDProcess () {
  if (Alerting) {
    Serial.println("LED set Hi");
    digitalWrite(LEDg, LOW);
    digitalWrite(LEDr, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(1000);                       // wait for a second
    digitalWrite(LEDr, LOW);    // turn the LED off by making the voltage LOW
    delay(1000);                       // wait for a second
  } else {
    // Serial.println("setting LED LOW");
    digitalWrite(LEDr, LOW);
    digitalWrite(LEDg, HIGH);
  }
}

//AlarmProcess
void AlarmProcess() {
  if (Alerting) {
    unsigned char i;
    for (i = 0; i < 10; i++)
    {
      digitalWrite(buzzer, HIGH);
      delay(Timer3);//wait for 10ms
      digitalWrite(buzzer, LOW);
      delay(Timer3);//wait for 10ms
    }
   
    for (i = 0; i < 20; i++)
    {
      digitalWrite(buzzer, HIGH);
      delay(Timer2);//wait for 20ms
      digitalWrite(buzzer, LOW);
      delay(Timer2);//wait for 20ms
    }
  }
}

//WindowProcess
void WindowProcess() {
    WindowContact = digitalRead(WINDOW);                                //read WINDOW state from WINDOW
    if (WindowContact == HIGH && systemState == ARMED){                 //If WINDOWState high and the systemState is ARMED
      lcd.setCursor(6,0);                                             //set cursor to 6,0
      lcd.print("Window Contact Broken");                                            //Print WINDOW
      AlarmActivation = true;  }                                        //ActivateAlert True
      else{
      AlarmActivation = false;                                        //If not Activate Alert False
        }
        if (AlarmActivation) {
          Serial.println("AlarmActivation");
          }  
          SirenSequence();                                            //Carry out SirenSequence
          LEDSequence();                                              //Carry out LEDSequence
          LEDSequence();
          LEDSequence();
          LEDSequence();
          }


I havent tidied it up FYI

Did you install the library ?

https://playground.arduino.cc/Code/Keypad/

void LCDstartupProcess() {

Let's play "find the matching brace"

If you had, you would have already found the problem

A standard C++ program would require all functions to be declared before being used. This can be done by changing the order in which they appear in the program or by placing a function prototype at the start of the program even if the actual function definition is much further down

This is not usually necessary in the Arduino environment because it is done automatically by the pre-processor when the sketch is compiled but sometimes this fails to happen which is what appears to be happening here

The solution is to add function prototypes near the start of the sketch like this

#include <Keypad.h>
#include <LiquidCrystal.h>

void  LCDstartupProcess();
void  KeypadProcess();
void  PIRProcess();
void  AlarmProcess();
void  WindowProcess();

int Timer1 = 10000;
//etc

You will then get an error on this line

  String a = getStateString(SystemStates);

because you cannot pass an enum to a function and I am not sure what you are trying to do. Somewhere along the line you seem to have confused the SystemStates enum with the current value of AlarmState

The error in the topic title is often caused by missing / misplaced curly braces.

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with your project.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.