Proteus simulation - RF ID LOCK with I2c LCD display
// install the required libraries
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x20, 16, 2);//set correct address of the I2c module
int count = 0;// variable "count"is int type
char c;// variable "c" is char type
String id;//variable "id"is string type
void setup() {
Serial.begin(9600);//set baud rate 9600
lcd.begin();// initilize lcd screen
pinMode(13, OUTPUT);// set pin for lock
Serial.println("Please scan ID CARD");//printing command on serial monitor
lcd.backlight();//turning on Backlight of LCD screen
lcd.print("SCAN ID CARD");//printing message on LCD screen.
}
void loop() {
while (Serial.available() > 0)
{
c = Serial.read();
count++;
id += c;
if (count == 12)
{
Serial.print(id);
//break;
if (id == "AB123456789A")//Enter 12 characer RF ID Card number here
{
Serial.println("CARD IS VALID");// printing message on the serial monitor
Serial.println("ACCESS ALLOWED");
lcd.clear();// commad for clear the LCD screen
lcd.setCursor(0, 0); //command for set the Character position on the LCD(first column/top raw)
lcd.print("CARD IS VALID");// printing message on the LCD Screen
lcd.setCursor(0, 1); //command for set the Character position on the LCD(first column/bottom raw)
lcd.print("ACCESS ALLOWED");//printing message on the LCD sreen
digitalWrite(13, HIGH);// command for open the Lock
}
else
{
digitalWrite(13, LOW);//command for keep close the lock
Serial.println("-is an Invalid TAG");// printing message on the serial monitor
Serial.println("ACCESS DENIED!!");// printing message on the serial monitor
lcd.clear();//command for clear the LCD screen
lcd.setCursor(0, 0); //command for set the Character position on the LCD(first column/top raw)
lcd.print("CARD IS INVALID");//printing message on the LCD screen
lcd.setCursor(0, 1); //command for set the Character position on the LCD(first column/bottom raw)
lcd.print("ACCESS DENIED");//printing message on LCD screen
}
}
}
count = 0;
id = "";
delay(500);
}
Comments
Post a Comment