Hello im having problem getting the RFID MFRC522 Working.
I got the project tutorial from:
and i follow all the steps.
When iam trying to upload the last code, i got the following error messages:
Users/users/Documents/Arduino/RFID_PROXIMITY_LCD/RFID_PROXIMITY_LCD.ino: In function 'void loop()':
/Users/users/Documents/Arduino/RFID_PROXIMITY_LCD/RFID_PROXIMITY_LCD.ino:89:25: warning: deprecated conversion from string constant to 'char*' [-Wwrite-strings]
myTags = "";
^* And my LCD shows nothing! Its blank! Please help me. I appreciate any answers. Thank you so much!
It is a warning, not an error message. Warnings do not cause compilation to fail so that is not your problem. As for why the display is blank, have you initialized it? Have you tested it with other sample programs to make sure your contrast adjustment makes characters visible?
myServo.write(10); // Initial lock position of the servo motor
// Prints the initial message
lcd.print("-No Master Tag!-");
lcd.setCursor(0, 1);
lcd.print(" SCAN NOW");
// Waits until a master card is scanned
while (!successRead) {
successRead = getID();
if ( successRead == true) {
myTags[tagsCount] = strdup(tagID.c_str()); // Sets the master tag into position 0 in the array
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Master Tag Set!");
tagsCount++;
}
}
successRead = false;
printNormalModeMessage();
}
void loop() {
int proximitySensor = analogRead(A0);
// If door is closed...
if (proximitySensor > 200) {
if ( ! mfrc522.PICC_IsNewCardPresent()) { //If a new PICC placed to RFID reader continue
return;
}
if ( ! mfrc522.PICC_ReadCardSerial()) { //Since a PICC placed get Serial and continue
return;
}
tagID = "";
// The MIFARE PICCs that we use have 4 byte UID
for ( uint8_t i = 0; i < 4; i++) { //
readCard = mfrc522.uid.uidByte*;* _ tagID.concat(String(mfrc522.uid.uidByte*, HEX)); // Adds the 4 bytes in a single String variable*
* } tagID.toUpperCase();_ mfrc522.PICC_HaltA(); // Stop reading* * correctTag = false;* * // Checks whether the scanned tag is the master tag* * if (tagID == myTags[0]) {* * lcd.clear();* * lcd.print("Program mode:");* * lcd.setCursor(0, 1);* * lcd.print("Add/Remove Tag");* * while (!successRead) {* * successRead = getID();* * if ( successRead == true) {* * for (int i = 0; i < 100; i++) {* _ if (tagID == myTags*) { myTags = ""; lcd.clear(); lcd.setCursor(0, 0); lcd.print(" Tag Removed!"); printNormalModeMessage(); return; } }_ myTags[tagsCount] = strdup(tagID.c_str()); _ lcd.clear(); lcd.setCursor(0, 0); lcd.print(" Tag Added!"); printNormalModeMessage(); tagsCount++; return; } } } successRead = false; // Checks whether the scanned tag is authorized* * for (int i = 0; i < 100; i++) { if (tagID == myTags) { lcd.clear(); lcd.setCursor(0, 0); lcd.print(" Access Granted!"); myServo.write(170); // Unlocks the door* * printNormalModeMessage(); correctTag = true; } } if (correctTag == false) { lcd.clear(); lcd.setCursor(0, 0); lcd.print(" Access Denied!"); printNormalModeMessage(); } } // If door is open... else { lcd.clear(); lcd.setCursor(0, 0); lcd.print(" Door Opened!"); while (!doorOpened) { proximitySensor = analogRead(A0); if (proximitySensor > 200) { doorOpened = true; } } doorOpened = false; delay(500); myServo.write(10); // Locks the door* * printNormalModeMessage(); } } uint8_t getID() { // Getting ready for Reading PICCs* * if ( ! mfrc522.PICC_IsNewCardPresent()) { //If a new PICC placed to RFID reader continue* * return 0; }_ if ( ! mfrc522.PICC_ReadCardSerial()) { //Since a PICC placed get Serial and continue* * return 0;* * }* * tagID = "";* * for ( uint8_t i = 0; i < 4; i++) { // The MIFARE PICCs that we use have 4 byte UID* readCard = mfrc522.uid.uidByte*;* _ tagID.concat(String(mfrc522.uid.uidByte*, HEX)); // Adds the 4 bytes in a single String variable* * } tagID.toUpperCase();_ mfrc522.PICC_HaltA(); // Stop reading* * return 1;* } void printNormalModeMessage() { * delay(1500);* * lcd.clear();* * lcd.print("-Access Control-");* * lcd.setCursor(0, 1);* * lcd.print(" Scan Your Tag!");* }
Reply #3 makes it sound like you assume the LCD is working because the backlight is on, but just because the backlight is on does not mean you will be able to write characters to it. You need to follow the advice in reply #1 and try a known working program to test the LCD.
Open the test program at File=>Examples=>LiquidCrystal=>HelloWorld. Note that you might have to change the parameters used to initialize the library.
If it does not work check your wiring (and as suggested in reply #1 the contrast pot) and follow the LCD tutorial on the Arduino web site.
If you cannot get the LiquidCrystal examples to work then you're wasting your time trying to get the lock program working.
After a day, i solved it! I could make it work with adding 220 resistor too the 5V!
I combined it with the "Hello World" LCD Project
But i got 1 problem
So let s say i came home from school, i bring my tag, i scan it, granted, i go inside my room and sleep. (HAHA).
And now, How can i go outside of my room because the the servo status is locked.
So what i want is, how to get out of my room when im inside of my room (because i set the MFRC522 outside of the door) ?
(+)
My Project drains 9v battery so fast! How can i prevent that. I can tell that is drain battery fast because the LCD getting darker and darker untill all the text gone. Help me