Hi everyone,
I am having some issues with the 16x2 LCD Display from the Genuino Starter Kit.
I want to build a NFC authenticator using the Seeed Studio NFC Shield v1.0. When starting the program, the text on the LCD display should say something like "Scan your NFC Tag here".
If the scanned NFC Tag is correct, it should say "Correct NFC Tag", otherwise it should say "Wrong NFC Tag".
Here's the code of my program:
// include the library code:
#include <LiquidCrystal.h>
#include <PN532.h>
#include <SPI.h>
#define PN532_CS 10
PN532 nfc(PN532_CS);
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
Serial.begin(9600);
Serial.println("Hello!");
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Scan NFC Tag to");
lcd.setCursor(0,1);
lcd.print("open the box!");
nfc.begin();
nfc.SAMConfig();
}
void loop() {
uint32_t id;
id = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A);
if (id == 4218538142) {
lcd.clear();
lcd.print("Code correct!");
lcd.setCursor(0,1);
lcd.print("Open the box!");
}
else if (id != 4218538142) {
lcd.clear();
lcd.print("Wrong code!");
lcd.setCursor(0,1);
lcd.print("Try again!");
}
}
The NFC code is derived from the sketch "readMifareTargetID" combined with LCD Display code elements.
#include <PN532.h>
#include <SPI.h>
/*Chip select pin can be connected to D10 or D9 which is hareware optional*/
/*if you the version of NFC Shield from SeeedStudio is v2.0.*/
#define PN532_CS 10
PN532 nfc(PN532_CS);
#define NFC_DEMO_DEBUG 1
void setup(void) {
#ifdef NFC_DEMO_DEBUG
Serial.begin(9600);
Serial.println("Hello!");
#endif
nfc.begin();
uint32_t versiondata = nfc.getFirmwareVersion();
if (! versiondata) {
#ifdef NFC_DEMO_DEBUG
Serial.print("Didn't find PN53x board");
#endif
while (1); // halt
}
#ifdef NFC_DEMO_DEBUG
// Got ok data, print it out!
Serial.print("Found chip PN5");
Serial.println((versiondata>>24) & 0xFF, HEX);
Serial.print("Firmware ver. ");
Serial.print((versiondata>>16) & 0xFF, DEC);
Serial.print('.');
Serial.println((versiondata>>8) & 0xFF, DEC);
Serial.print("Supports ");
Serial.println(versiondata & 0xFF, HEX);
#endif
// configure board to read RFID tags and cards
nfc.SAMConfig();
}
void loop(void) {
uint32_t id;
// look for MiFare type cards
id = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A);
if (id != 0) {
#ifdef NFC_DEMO_DEBUG
Serial.print("Read card #");
Serial.println(id);
#endif
}
if (id == 4218538142) {
lcd.clear();
lcd.print("Code correct!");
lcd.setCursor(0,1);
lcd.print("Open the box!");
}
else if (id != 4218538142) {
lcd.clear();
lcd.print("Wrong code!");
lcd.setCursor(0,1);
lcd.print("Try again!");
}
}
Attached you will find a picture of the wiring.
Whenever I try to run the program now, the text "Scan NFC tag to open the box!" appears, but after a while the letters disappear until the screen is blank.
In the serial monitor I can see that the Code from the Mifare Card is scanned, but nothing appears on the screen.
When I clear the void loop() section the letters stay on the screen, but with the shown code the display goes blank.
Does anybody know what my mistake is?
Any help is highly appreciated!
Cheers,
Tractorbeam

