return;
}
else {
int total
= 0;
for (int ct=0;
ct
< kTags;
ct++){
total
+= checkTag(newTag,
knownTags[ct]);
}
//
If
newTag
matched
any
of
the
tags
//
we
checked
against,
total
will
be
1
if (total
> 0)
{
//
Put
the
action
of
your
choice
here!
//
I'm
going
to
rotate
the
servo
to
symbolize
unlocking
the
lockbox
Serial.println("Success!");
lockServo.write(180);
}
else {
//
This
prints
out
unknown
cards
so
you
can
add
them
t
o
your
knownTags
as
needed
Serial.print("Unknown
tag!
");
Serial.print(newTag);
Serial.println();
}
}
//
Once
newTag
has
been
checked,
fill
it
with
zeroes
//
to
get
ready
for
the
next
tag
read
for (int c=0;
c
< idLen;
c++)
{
newTag[c]
= 0;
}
}
//
This
function
steps
through
both
newTag
and
one
of
the
know
n
//
tags.
If
there
is
a
mismatch
anywhere
in
the
tag,
it
will
r
eturn
0,
//
but
if
every
character
in
the
tag
is
the
same,
it
returns
1
int checkTag(char nTag[],
char oTag[])
{
for (int i
= 0;
i
< idLen;
i++)
{
if (nTag[i]
!= oTag[i])
{
return 0;
}
}
return 1;
}
Using the RFID Reader Breakout
For Arduino projects, you can also use the SparkFun RFID Reader
Breakout which gives the module a place to sit and breaks out its odd 2mm-
pitch pins to a breadboard-friendly 0.1" spacing.
To keep the module removable (and protect it from accidental damage
during soldering), you can trim 2x 2mm Xbee Sockets to size and solder
them to the top of the breakout.
Page 9 of 10