Reading NFC Tag

I am working on a project to read NFC Tags. I wrote a program referring an Adafruit library.
I modified the program a bit so that it allows only authorized users to access the system.
I have attached the code that i have written. It isn't working the right way Please help.

NFCtag.ino (1.36 KB)

#include <Wire.h>
#include <SPI.h>
#include <Adafruit_PN532.h>

#define PN532_IRQ (2)
#define PN532_RESET (3)

Adafruit_PN532 nfc(PN532_IRQ, PN532_RESET);

void setup(void)
{
Serial.begin(9600);
Serial.println("Hello there!");

nfc.begin();
nfc.SAMConfig();

Serial.println("Waiting for a customer...");
}

void loop(void)
{
uint8_t success;
uint8_t Uid[] = {0, 0, 0, 0, 0, 0, 0};
uint8_t abel[] = {126, 1, 178, 132, 42, 132, 7};
uint8_t yuj[]={39, 119, 15, 0};
boolean a_card = true;
boolean y_card=true;

uint8_t uidLength;
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, Uid, &uidLength);

Serial.print(Uid[1], DEC);

if (success)
{
Serial.println("Found User");
Serial.print(" UID Length: "); Serial.print(uidLength, DEC); Serial.println(" bytes");
Serial.print(" UID Value: ");
for (uint8_t i = 1; i <= uidLength; i++)
{

Serial.print(Uid*, DEC);*

  • Serial.print(" ");*
    if (Uid != abel*) a_card = false;
    if (Uid != yuj) y_card = false;*

* }*
* if (a_card==true) Serial.println("Welcome Abel");
if (y_card==true) Serial.println("Welcome YUJ");
_ else Serial.println("Invalid");
// Wait 1 second before continuing*

* delay(1000);
Serial.println("");
Serial.println("\n\nScan another tag!");
Serial.flush();*_

* Serial.flush();*
* }*
}

Try ...

if (Uid[i] != abel[i]) ...

Also, array elements start from element 0. So change your for loop to ...

for (uint8_t i = 0; i < uidLength; i++)

It isn't working the right way

It does something. You have not explained what it does.
You expect it to do something. You have not explained what you expect it to do.

Perhaps you simply need to re-align your expectations.

It wasn't detecting authorized IDs.
Well, thanks to Hackscribble:)
Thank you so much.
It was a careless mistake..
:smiley: