Hello!
I am new to this forum and just started a new project for my school contest.
And... there has been a programming-related problem that I couldn't figure it out.
I have purchased Arduino Uno and Adafruit PN532 NFC Module for my project.
Am sort of trying to create program which reads RFID tags, its UID and so on.
During research for the wiring, I found an exmaple code from Adafruit which reads tag info from the module and prints it by Serial monitor.
(It is using I2C connection.)
It worked perfectly, so I used it. But later, I wanted to add more practical functions.
For example, if the tag was acting like an ID card, which students or workers use in the entrance of the building,
and automatically logs the whole thing with Time-stamp and saves it into .txt or .csv file, etc.
So I searched what do I have to download(or edit), and found a program named CoolTerm,
which records the Serial Monitor output into a file. It worked, so I kept going on.
In order to sort out the tag which is read once or twice, I thought what if the tag has a integer value which is set to 0 by default.
When the tag is read once, the value adds 1, resulting the value to be 1. When the same tag is read again, it subtracts 1, resulting the value to be 0.
I thought it was an OK idea. So I programmed it on my own. It didn't have any compile error.
When I uploaded it and simulated the system as I planned, it had a problem.
The value is set to 0 permanently(or the value doesn't add up to 1.).
I am attaching source file, and a serial monitor result image.
How should I fix this error, or improve the code? It seems to be very simple yet I couldn't figure it out.
Any suggestions or solutions regarding this code would be very appreciated.
Regards,
Reggie
iso14443a_uid_edited.ino (2.26 KB)
iso14443a_uid.ino (3.19 KB)