2
2
#include < MFRC522.h>
3
3
#include < Keypad.h>
4
4
#include < SPI.h>
5
+ #include < LiquidCrystal.h>
5
6
6
7
// RFID
7
- #define SS_PIN 10
8
- #define RST_PIN 9
9
- #define solenoidPin 11
8
+ #define SS_PIN 6
9
+ #define RST_PIN 5
10
+ #define solenoidPin 4
10
11
MFRC522 rfid (SS_PIN, RST_PIN);
11
12
13
+ const int rs = 12 ; // Digital Pin 12
14
+ const int en = 11 ; // Digital Pin 11
15
+ const int d6 = 10 ; // Digital Pin 10
16
+ const int d4 = 9 ; // Digital Pin 9
17
+ const int d5 = 8 ; // Digital Pin 8
18
+ const int d7 = 7 ; // Digital Pin 7
19
+
12
20
// Keypad
13
21
const byte ROWS = 4 ; // Four rows
14
22
const byte COLS = 3 ; // Three columns
@@ -22,17 +30,21 @@ byte rowPins[ROWS] = {9, 8, 7, 6}; // Connect to the row pinouts of the keypad
22
30
byte colPins[COLS] = {5 , 4 , 3 }; // Connect to the column pinouts of the keypad
23
31
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
24
32
25
- // Kullanıcı RFID kartları ve şifreler
33
+ // Users RFID PASSWORD NAME
26
34
String validCards[] = {" CARD1_UID" , " CARD2_UID" };
27
35
String userPasswords[] = {" 1234" , " 5678" };
28
36
String userNames[] = {" X" , " Y" };
29
37
38
+ // LCD
39
+ LiquidCrystal lcd (rs, en, d4, d5, d6, d7);
40
+
30
41
String enteredPassword = " " ;
31
42
32
43
void setup () {
33
44
Serial.begin (115200 );
34
45
SPI.begin ();
35
46
rfid.PCD_Init ();
47
+ lcd.begin (16 , 2 ); // initialize the lcd for 16 chars 2 lines, turn on backlight
36
48
}
37
49
38
50
void loop () {
@@ -53,6 +65,7 @@ void loop() {
53
65
if (isValidCard (cardUID)) {
54
66
String user = getUserByCard (cardUID);
55
67
openDoor ();
68
+ displayGreeting (user, cardUID);
56
69
Serial.print (" Hello " );
57
70
Serial.println (user);
58
71
sendResultToJetson (" Hello " + user);
@@ -67,6 +80,7 @@ void loop() {
67
80
if (isValidPassword (enteredPassword)) {
68
81
String user = getUserByPassword (enteredPassword);
69
82
openDoor ();
83
+ displayGreeting (user, " PASSWORD" );
70
84
Serial.print (" Hello " );
71
85
Serial.println (user);
72
86
sendResultToJetson (" Hello " + user);
@@ -115,13 +129,21 @@ String getUserByPassword(String password) {
115
129
}
116
130
117
131
void openDoor () {
118
-
119
132
digitalWrite (solenoidPin, HIGH);
120
- sleep (1 );
133
+ delay (1000 ); // 1 second delay
134
+ digitalWrite (solenoidPin, LOW);
121
135
}
122
136
123
137
void sendResultToJetson (String message) {
124
138
Serial.print (" RESULT:" );
125
139
Serial.println (message);
126
140
}
127
141
142
+ void displayGreeting (String user, String identifier) {
143
+ lcd.clear ();
144
+ lcd.setCursor (0 , 0 );
145
+ lcd.print (" Merhaba " );
146
+ lcd.print (user);
147
+ lcd.setCursor (0 , 1 );
148
+ lcd.print (identifier);
149
+ }
0 commit comments