Professional Documents
Culture Documents
Security Door Code
Security Door Code
h>
Servo servo_10;
#include <Keypad.h>
void setup() {
servo_10.attach(10, 500, 2500);
Serial.begin(9600);
pinMode(11, OUTPUT);
servo_10.write(0);
void loop() {
static String inputCode = ""; // String to store the entered code
if (key != NO_KEY) {
if (key == 'C') {
inputCode = ""; // Reset the input code if c is pressed
} else {
inputCode += key; // Append the pressed key to the input code
}
if (inputCode.length() == 1) {
if (inputCode == "B") {
servo_10.write(0);
inputCode = "";
}
if (inputCode == "A") {
digitalWrite(11, LOW);
inputCode = "";
}
if (inputCode =="C") {
inputCode="";
}
}
if (inputCode.length() == 4) {
if (inputCode =="7545") {
servo_10.write(80);
} else {
servo_10.write(0);
digitalWrite(11, HIGH);
}
inputCode = "";
}
delay(100);
}