#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <MFRC522.h>
#include <Servo.h>
#define SERVO_PIN 2
Servo myservo;
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN); // Create MFRC522 instance.
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
Serial.begin(9600);
SPI.begin();
lcd.init();
lcd.backlight();
mfrc522.PCD_Init();
Serial.println("Arduino RFID door lock");
mfrc522.PCD_DumpVersionToSerial();
myservo.attach(SERVO_PIN);
opendoor();
}
void opendoor(){
lcd.setCursor(0,0);
lcd.print("Welcome: Guest");
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Door closes in");
lcd.setCursor(0,1);
lcd.print("5");
lcd.clear();
delay(1000);
lcd.setCursor(0,1);
lcd.print("4");
lcd.clear();
delay(1000);
lcd.setCursor(0,1);
lcd.print("3");
lcd.clear();
delay(1000);
lcd.setCursor(0,1);
lcd.print("2");
lcd.clear();
delay(1000);
lcd.setCursor(0,1);
lcd.print("1");
lcd.clear();
delay(1000);
myservo.write( 0 );
}
void jordan(){
lcd.setCursor(0,0);
lcd.print("Welcome: Jordan");
myservo.write( 380 );
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Door closes in");
lcd.setCursor(0,1);
lcd.print("5");
lcd.clear();
delay(1000);
lcd.setCursor(0,1);
lcd.print("4");
lcd.clear();
delay(1000);
lcd.setCursor(0,1);
lcd.print("3");
lcd.clear();
delay(1000);
lcd.setCursor(0,1);
lcd.print("2");
lcd.clear();
delay(1000);
lcd.setCursor(0,1);
lcd.print("1");
lcd.clear();
delay(1000);
myservo.write( 0 );
}
void savio(){
lcd.setCursor(0,0);
lcd.print("Welcome: Savio");
myservo.write( 380 );
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Door closes in");
lcd.setCursor(0,1);
lcd.print("5");
lcd.clear();
delay(1000);
lcd.setCursor(0,1);
lcd.print("4");
lcd.clear();
delay(1000);
lcd.setCursor(0,1);
lcd.print("3");
lcd.clear();
delay(1000);
lcd.setCursor(0,1);
lcd.print("2");
lcd.clear();
delay(1000);
lcd.setCursor(0,1);
lcd.print("1");
lcd.clear();
delay(1000);
myservo.write( 0 );
}
void jill(){
lcd.setCursor(0,0);
lcd.print("Welcome: Jill");
myservo.write( 380 );
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Door closes in");
lcd.setCursor(0,1);
lcd.print("5");
lcd.clear();
delay(1000);
lcd.setCursor(0,1);
lcd.print("4");
lcd.clear();
delay(1000);
lcd.setCursor(0,1);
lcd.print("3");
lcd.clear();
delay(1000);
lcd.setCursor(0,1);
lcd.print("2");
lcd.clear();
delay(1000);
lcd.setCursor(0,1);
lcd.print("1");
lcd.clear();
delay(1000);
myservo.write( 0 );
}
void sophia(){
lcd.setCursor(0,0);
lcd.print("Welcome: Sophia");
myservo.write( 380 );
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Door closes in");
lcd.setCursor(0,1);
lcd.print("5");
lcd.clear();
delay(1000);
lcd.setCursor(0,1);
lcd.print("4");
lcd.clear();
delay(1000);
lcd.setCursor(0,1);
lcd.print("3");
lcd.clear();
delay(1000);
lcd.setCursor(0,1);
lcd.print("2");
lcd.clear();
delay(1000);
lcd.setCursor(0,1);
lcd.print("1");
lcd.clear();
delay(1000);
myservo.write( 0 );
}
void loop(){
//Look for new cards
if ( !mfrc522.PICC_IsNewCardPresent() ){
return;
}
//Select one of the cards
if ( !mfrc522.PICC_ReadCardSerial() ) {
return;
}
Serial.print("UID tag :");
String content= "";
byte letter;
for( byte i = 0; i < mfrc522.uid.size; i++ ){
Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], HEX));
}
content.toUpperCase();
Serial.println();
Serial.println("UID tag :'" + content + "'");
if ( content == "D4-73-CA-2A" || "D7-75-2A-7B" || "97-15-35-7B" || "D7-2C-36-7B" || "F7-F4-29-7B" || "67-72-39-7B" || "D7-7A-2C-7B" || "27-17-27-7B" || "F7-DB-37-7B" ){
Serial.println("Guest");
delay(300);
opendoor();
}
if ( content == "D4-73-CA-2A" || "D7-75-2A-7B" || "97-15-35-7B" || "D7-2C-36-7B" || "F7-F4-29-7B" || "67-72-39-7B" || "D7-7A-2C-7B" || "27-17-27-7B" || "F7-DB-37-7B" ){
Serial.println("jordan");
delay(300);
jordan();
}
if ( content == "D4-73-CA-2A" || "D7-75-2A-7B" || "97-15-35-7B" || "D7-2C-36-7B" || "F7-F4-29-7B" || "67-72-39-7B" || "D7-7A-2C-7B" || "27-17-27-7B" || "F7-DB-37-7B" ){
Serial.println("sophia");
Serial.println(content);
delay(300);
sophia();
}if ( content == "D4-73-CA-2A" || "D7-75-2A-7B" || "97-15-35-7B" || "D7-2C-36-7B" || "F7-F4-29-7B" || "67-72-39-7B" || "D7-7A-2C-7B" || "27-17-27-7B" || "F7-DB-37-7B" ){
Serial.println("jill");
delay(300);
jill();
}
if ( content == "D4-73-CA-2A" || "D7-75-2A-7B" || "97-15-35-7B" || "D7-2C-36-7B" || "F7-F4-29-7B" || "67-72-39-7B" || "D7-7A-2C-7B" || "27-17-27-7B" || "F7-DB-37-7B" ){
Serial.println("savio");
delay(300);
savio();
}
}
@arduinodeveloper99, your topic has been moved to a more suitable location on the forum.
I'm quite sure that this issue has been reported a couple of times, did you do a search?
Nothing matches my problem
If that is no help, adjust the contrast and post a better photos of the display. I cannot see the display very well in the video.
Post a couple of photos directly into the discussion thread.
Hi,
What do you mean by half of the text?
displays one line instead of two?
displays characters that are cutoff halfway on each line.
displays characters halfway across the screen?
@Paul_B 's suggestion is a good one.
Please do not go back and add information to you first post.
Make a new post for your video.
Thanks... Tom...
Hi,
Remove all those LCD clear statements, the fact that you are writing a single digit number over the top of the previous, does not need the clear statement.
Your code actually writes the digit, then clears it ,then waits 1000ms display time, BUT you have cleared it previously with the clear statement.
It is on the screen for too short a time to see.
Tom....
i didnt quite get it can you please edit the code and send it to me
Hi,
I have edited your "sophia" function, you can shorten the code with a for loop.
void sophia(){
lcd.setCursor(0,0);
lcd.print("Welcome: Sophia");
myservo.write( 380 );
delay(1000);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Door closes in");
lcd.setCursor(0,1);
lcd.print("5");
delay(1000);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("4");
delay(1000);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("3");
delay(1000);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("2");
delay(1000);
lcd.clear();
lcd.setCursor(0,1);
lcd.print("1");
delay(1000);
lcd.clear();
myservo.write( 0 );
}
This will get you back on track, your other functions will need similar editing.
Tom...
thanks!!!
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.