Skip to content

Instantly share code, notes, and snippets.

@ThaiEasyElec
Last active July 23, 2019 10:36
Show Gist options
  • Save ThaiEasyElec/143d7c50c4c25504f23f211f17c6bde9 to your computer and use it in GitHub Desktop.
Save ThaiEasyElec/143d7c50c4c25504f23f211f17c6bde9 to your computer and use it in GitHub Desktop.
Home Alarm System
//take care of some special events
void keypadEvent(KeypadEvent eKey){
switch (keypad.getState()){
case PRESSED:
//Serial.print("Pressed: ");
//Serial.println(eKey);
lcd.setCursor(dir1, 3);
lcd.print(test);
test = "*";
lcd.setCursor(dir, 3);
lcd.print(test);
dir1 = dir;
switch (eKey){
case 'A':
if(fl == 1){
if(state == 0){
digitalWrite(led_bed, HIGH); // Open the light 2
state = 1;
}else if(state == 1){
digitalWrite(led_bed, LOW); // Close the light 2
state = 0;
}
}
break;
case 'B':
if(fl == 1){
if(state1 == 0){
digitalWrite(led_bath, HIGH); // Open the light 1
state1 = 1;
}else if(state1 == 1){
digitalWrite(led_bath, LOW); // Close the light 1
state1 = 0;
}
}
break;
case 'C':
if(fl == 1){
state2 = 1;
lcd.setCursor(0, 3);
lcd.print(" ** Home Lock ** ");
dir = 8;
dir1 = 0;
test = " ";
}
break;
case '#':
checkPassword(); // Call the function checkPassword
password.reset(); //Reset Key
break;
default:
password.append(eKey);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment