-
Notifications
You must be signed in to change notification settings - Fork 0
/
finalpro.ino.ino
149 lines (112 loc) · 3.86 KB
/
finalpro.ino.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/* add the librarie for EEPROM*/
#include <EEPROM.h>
/* I have not used the Buzzer but included the code in the file */
boolean stringComplete = false;
String inputString = "";
int n = 0;
#define BUZZ 8 /* initialize the buzzer pin as d8 */
#define led 13 /*initialize the led pin as D13 */
#define SW1 3 /*initialize the SW1 pin of the RFID reader as D3 */
/* add the library for RTC module*/
#include<DS3231.h>
DS3231 rtc(SDA,SCL);
int count1=0; /* add the number of counters based on the number of names added */
int count2=0;
int count3=0;
char* names[]={"RANIT","LAL","ANDY"}; /* add the names to the database to keep track */
int i=0;
void setup() {
Serial.begin(9600);
rtc.begin();
rtc.setDOW(THURSDAY); /* set the DATE OF WEEK */
rtc.setTime(12,0,0); /* set the present time */
rtc.setDate(1,1,2019); /* set the present date */
pinMode(BUZZ,OUTPUT);
pinMode(led,OUTPUT);
pinMode(SW1,INPUT);
inputString.reserve(200);
}
void loop() {
if(stringComplete){
Serial.println(inputString);
if(inputString.equals("270016FAAA61")){//A
count1+=1; /* RFID tag for the first person and if the string printed in the serial window matches with the RFID tag the increment*/
digitalWrite(BUZZ,HIGH);
digitalWrite(led,HIGH);
delay(500);
digitalWrite(led,LOW);
if(count1%2!=0) /* if the count1 is odd it means an 'ENTRY' is made by person 1 assuming the room is initially empty */
{
Serial.println("A IS MARKED PRESENT");
}
else
{
Serial.println("A IS MARKED ABSENT");
}
Serial.println(rtc.getDOWStr()); /* prints the DATE OF THE WEEK in the serial monitor*/
Serial.print(" ");
Serial.println(rtc.getTimeStr()); /* prints the TIME in the serial monitor */
Serial.print("--");
Serial.println(rtc.getDateStr()); /* prints the DATE in the serial monitor */
Serial.print("--");
Serial.print(count1);
}
if(inputString.equals("270022B39620")){//B
count2+=1;
digitalWrite(BUZZ,LOW);
digitalWrite(led,HIGH);
delay(500);
digitalWrite(led,LOW);
if(count2%2!=0)
{
Serial.println("B IS MARKED PRESENT");
}
else
{
Serial.println("B IS MARKED ABSENT");
}
Serial.println(rtc.getDOWStr());
Serial.print(" ");
Serial.println(rtc.getTimeStr());
Serial.print("--");
Serial.println(rtc.getDateStr());
Serial.print("--");
Serial.print(count2);
}
if(inputString.equals("27001674B8FD")){//c
count3+=1;
digitalWrite(BUZZ,LOW);
digitalWrite(led,HIGH);
delay(500);
digitalWrite(led,LOW);
if(count3%2!=0)
{
Serial.println("C IS MARKED PRESENT");
}
else
{
Serial.println("C IS MARKED ABSENT");
}
Serial.println(rtc.getDOWStr());
Serial.print(" ");
Serial.println(rtc.getTimeStr());
Serial.print("--");
Serial.println(rtc.getDateStr());
Serial.print("--");
Serial.print(count3);
}
stringComplete = false;
inputString = "";
}
}
void serialEvent(){
while(Serial.available()){
n++;
char inChar = (char) Serial.read();
inputString += inChar;
if(n>=12){
n=0;
stringComplete = true;
}
}
}