1
2
3
4
5#include <Servo.h>
6Servo servoNesnesi;
7
8#include <Keypad.h>
9String pasword1="Your password";
10String pasword2="";
11int p=0;
12
13
14const byte ROWS = 4;
15const byte COLS = 3;
16
17char keys[ROWS][COLS] = {
18 {'1','2','3'},
19 {'4','5','6'},
20 {'7','8','9'},
21 {'*','0','#'}
22};
23byte rowPins[ROWS] = {9, 8, 7, 6};
24byte colPins[COLS] = {5, 4, 3};
25
26
27Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
28
29void setup(){
30 Serial.begin(9600);
31 #define BUZZERPIN 11
32
33 servoNesnesi.attach(10);
34 pinMode(BUZZERPIN,OUTPUT);
35
36 servoNesnesi.write(100);
37
38 Serial.begin(9600);
39
40}
41
42
43
44
45
46
47void loop(){
48 char key = keypad.getKey();
49
50
51 if (key){
52
53 Serial.print("Key print : ");
54 Serial.println(key);
55
56 digitalWrite(BUZZERPIN,HIGH);
57 delay(100);
58 digitalWrite(BUZZERPIN,LOW);
59 p = pasword2.length();
60 pasword2+= key;
61 Serial.println(pasword2);
62 }
63 if(pasword2 == pasword1){
64 servoNesnesi.write(20);
65 pasword2="";
66
67 }
68 else if(pasword2 !=pasword1 and p>= 6){
69
70 digitalWrite(BUZZERPIN,HIGH);
71 pasword2="";
72
73 }
74 if(key == '#'){
75 servoNesnesi.write(100);
76 pasword2="";
77
78
79 }
80
81 }
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98