Hello!
I have an RC522 NFC module wired to my Leonardo and if I touch an nfc tag it writes the UID of the tag down. That means if I want to realise an PC login I have to change my password to the UID of the tag. This method is ok but you will have to remember such a stupid combination of numbers and letters if you lost your tag. Like this everything works fine but it isnt a very good method. now I want that if my card is detected it writes down my password. And when someone else touches with his card, his password is entered.
Bzt the Problem is that I cant get it to work because I always get an error because of the tag ID. here is my code:
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 5
MFRC522 mfrc522(SS_PIN, RST_PIN);
char ctrlKey = KEY_RETURN;
void setup() {
Serial.begin(9600);
Keyboard.begin();
SPI.begin();
mfrc522.PCD_Init();
}
void loop() {
if (!mfrc522.PICC_IsNewCardPresent()) {
return;
}
if (!mfrc522.PICC_ReadCardSerial()) {
return;
}
mfrc522.PICC_DumpToSerial(&(mfrc522.uid)); //serial monitor
//Keyboard.press(ctrlKey);
//Keyboard.release(ctrlKey);
delay(300);
//You can add another character like '@' here.
//Keyboard.print('@');
//Keyboard.print('#');
//for (byte i = 0; i < 4; i++) { OLD CODE THAT WORKED FINE. IT PRINTS THE TAG OF THE UID OF THE TAG
//Keyboard.print(mfrc522.uid.uidByte[i], HEX); //e.g. C4AD6FB2
}
//THIS SHOULD BE THE NEW CODE . IF I TOUCH THE TAG WITH ID 14D33D77
//IT SHOULD PRINT mypasswd
if (mfrc522.uid.uidByte[i], HEX == 14D33D77) { //enter your UID
Keyboard.write('m');
Keyboard.write('y');
Keyboard.write('p');
Keyboard.write('a');
Keyboard.write('s');
Keyboard.write('s');
Keyboard.write('w');
Keyboard.write('d');
Keyboard.write(KEY_RETURN);
delay(1000);
}
//You can add another character like '@' here.
//Keyboard.print('3');
//Keyboard.print('4');
Keyboard.releaseAll();
delay(200);
Keyboard.press(ctrlKey);
Keyboard.releaseAll();
}
Any Ideas are welcome 
Thanks for your help 
Notes:
MAIN IDEA FROM HERE
USED LIBARY
What error do you get? Is it a compile error or a run time error.
Grumpy_Mike:
What error do you get? Is it a compile error or a run time error.
This is the error. I think something is wromg on my code. 
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 (Windows 7), Board: "Arduino Leonardo"
sketch_aug12a.ino:42:36: error: invalid suffix "D33D77" on integer constant
sketch_aug12a:42: error: expected unqualified-id before 'if'
sketch_aug12a:64: error: expected constructor, destructor, or type conversion before '.' token
sketch_aug12a:65: error: expected constructor, destructor, or type conversion before '(' token
sketch_aug12a:67: error: expected constructor, destructor, or type conversion before '.' token
sketch_aug12a:68: error: expected constructor, destructor, or type conversion before '.' token
sketch_aug12a:69: error: expected declaration before '}' token
You need to put a 0x in front of your tag ID to tell the compiler it is a hex value.
ok it seems to work there anre not that much errors left
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 (Windows 7), Board: "Arduino Leonardo"
sketch_aug12b.ino: In function 'void loop()':
sketch_aug12b:27: error: could not convert 'mfrc522.MFRC522::uid' to 'bool'
sketch_aug12b:27: error: expected primary-expression before '==' token
thanks
Have you removed that HEX from infront of the ==
Post that line again.
Grumpy_Mike:
Have you removed that HEX from infront of the ==
Post that line again.
Idont know which HEX you mean 
My code:
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 5
MFRC522 mfrc522(SS_PIN, RST_PIN);
char ctrlKey = KEY_RETURN;
void setup() {
Serial.begin(9600);
Keyboard.begin();
SPI.begin();
mfrc522.PCD_Init();
}
void loop() {
if (!mfrc522.PICC_IsNewCardPresent()) {
return;
}
if (!mfrc522.PICC_ReadCardSerial()) {
return;
}
mfrc522.PICC_DumpToSerial(&(mfrc522.uid)); //serial monitor
//Keyboard.press(ctrlKey);
//Keyboard.release(ctrlKey);
delay(300);
//for (byte i = 0; i < 4; i++) { OLD CODE THAT WORKED FINE. IT PRINTS THE TAG OF THE UID OF THE TAG
//Keyboard.print(mfrc522.uid.uidByte[i], HEX); //e.g. C4AD6FB2
}
//THIS SHOULD BE THE NEW CODE . IF I TOUCH THE TAG WITH ID 14D33D77
//IT SHOULD PRINT mypasswd
if (mfrc522.uid.uidByte[i], HEX == 14D33D77) { //enter your UID
Keyboard.write('m');
Keyboard.write('y');
Keyboard.write('p');
Keyboard.write('a');
Keyboard.write('s');
Keyboard.write('s');
Keyboard.write('w');
Keyboard.write('d');
Keyboard.write(KEY_RETURN);
delay(1000);
}
Keyboard.releaseAll();
delay(200);
Keyboard.press(ctrlKey);
Keyboard.releaseAll();
}
Looking at your code again it seems you are trying to com pair a byte with a long. You need to gather all the bytes from your tag ID into one long variable before you do the comparison.
if (mfrc522.uid.uidByte, HEX == 14D33D77) { //enter your UID
That HEX and use code tags.
Grumpy_Mike:
That HEX and use code tags.
Can you please give me the code with your code pasted because I dont know how you exactly mean 
( 4D33D77 is my uid i want to use)
Thanks for your help!!! 
if (mfrc522.uid.uidByte, HEX == 14D33D77) { //enter your UID
Should be
if (mfrc522.uid.uidByte == 0x14D33D77) { //enter your UID
BUT that assumes that the call to mfrc522.uid.uidByte actually returns a long type variable which I think it does not.
Last time warning, if you do not edit post #6 to include code tags I will not respond to any more posts in this thread.
Grumpy_Mike:
if (mfrc522.uid.uidByte, HEX == 14D33D77) { //enter your UID
Should be
if (mfrc522.uid.uidByte == 0x14D33D77) { //enter your UID
BUT that assumes that the call to mfrc522.uid.uidByte actually returns a long type variable which I think it does not.
Last time warning, if you do not edit post #6 to include code tags I will not respond to any more posts in this thread.
Grumpy_Mike:
if (mfrc522.uid.uidByte, HEX == 14D33D77) { //enter your UID
Should be
if (mfrc522.uid.uidByte == 0x14D33D77) { //enter your UID
BUT that assumes that the call to mfrc522.uid.uidByte actually returns a long type variable which I think it does not.
Last time warning, if you do not edit post #6 to include code tags I will not respond to any more posts in this thread.
Ok I edited post #6 - Sorry
But again got errors:
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.6 (Windows 7), Board: "Arduino Leonardo"
test.ino: In function 'void loop()':
test:27: error: could not convert 'mfrc522.MFRC522::uid' to 'bool'
test: error: expected primary-expression before '==' token
test:54: error: ISO C++ forbids comparison between pointer and integer
This error happens If I paste your code
Thanks
Where did you get the mfrc522 library from?
When I try and compile things I get totally different error messages suggesting we are not using the same library.
Also where did you get that code from. It is quite clear you did not write it yourself as you don't seem to be able to pick up on the help I am giving you.