Hex (MIFARE card) Number and EEPROM problem.
Posted: Wed Mar 10, 2021 4:12 pm
Hello everyone,
I have make my own project for personal use. My project is RFID Door.
I have dealing some problem while programming this project. First problem is when I use RFID Mifare card and then the lcd I2C screen should shows me Hex Number Like 2E EE B3 CC. But It show me one Hex number at time like 2E in first reading, EE in sec reading and etc. I want the 4 HEX number appear in one time. So how can I solve this problem?
Second problem is I use EEPROM to save MIFARE card data so it can operate normally even device has lost power. I have set one of other card as master key to going into programing mode. After that I have add card through program mode and it say success. But when I want to access in normal mode its say Cannot access. How I can solve my problem?
Below that is my code for two problem.
Problem 1:Master card reading HEX
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Master Card UID:");
for ( uint8_t i = 0; i < 4; i++ ) {
masterCard[i] = EEPROM.read(2 + i);
lcd.setCursor(0,1);
lcd.print(masterCard[i], HEX);
delay(3000);
----------------------------------------------------------
Problem 2:
void writeID( byte a[] ) {
if ( !findID( a ) ) { // Before we write to the EEPROM, check to see if we have seen this card before!
uint8_t num = EEPROM.read(0); // Get the numer of used spaces, position 0 stores the number of ID cards
uint8_t start = ( num * 4 ) + 6; // Figure out where the next slot starts
num++; // Increment the counter by one
EEPROM.write( 0, num ); // Write the new count to the counter
for ( uint8_t j = 0; j < 4; j++ ) { // Loop 4 times
EEPROM.write( start + j, a[j] ); // Write the array values to EEPROM in the right position
}
successWrite();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Good, ID has");
lcd.setCursor(0,1);
lcd.print("been added");
delay(3000);
}
else {
failedWrite();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Fail! something");
lcd.setCursor(0,1);
lcd.print("wrong @ID/EEPROM");
delay(3000);
}
}
I have make my own project for personal use. My project is RFID Door.
I have dealing some problem while programming this project. First problem is when I use RFID Mifare card and then the lcd I2C screen should shows me Hex Number Like 2E EE B3 CC. But It show me one Hex number at time like 2E in first reading, EE in sec reading and etc. I want the 4 HEX number appear in one time. So how can I solve this problem?
Second problem is I use EEPROM to save MIFARE card data so it can operate normally even device has lost power. I have set one of other card as master key to going into programing mode. After that I have add card through program mode and it say success. But when I want to access in normal mode its say Cannot access. How I can solve my problem?
Below that is my code for two problem.
Problem 1:Master card reading HEX
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Master Card UID:");
for ( uint8_t i = 0; i < 4; i++ ) {
masterCard[i] = EEPROM.read(2 + i);
lcd.setCursor(0,1);
lcd.print(masterCard[i], HEX);
delay(3000);
----------------------------------------------------------
Problem 2:
void writeID( byte a[] ) {
if ( !findID( a ) ) { // Before we write to the EEPROM, check to see if we have seen this card before!
uint8_t num = EEPROM.read(0); // Get the numer of used spaces, position 0 stores the number of ID cards
uint8_t start = ( num * 4 ) + 6; // Figure out where the next slot starts
num++; // Increment the counter by one
EEPROM.write( 0, num ); // Write the new count to the counter
for ( uint8_t j = 0; j < 4; j++ ) { // Loop 4 times
EEPROM.write( start + j, a[j] ); // Write the array values to EEPROM in the right position
}
successWrite();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Good, ID has");
lcd.setCursor(0,1);
lcd.print("been added");
delay(3000);
}
else {
failedWrite();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Fail! something");
lcd.setCursor(0,1);
lcd.print("wrong @ID/EEPROM");
delay(3000);
}
}