Hi, I'm really new to Arduino in particular and programming in general
And I need to read and write data to NFC chips.
The idea is to record a score of friends on the chips, I use a PN532 module connected to an Arduino Mega 256 board in this configuration:
VCC to 5 watts on the left,
GND to GND that is close to 5V.
SDA to pin 10
SCL to pin 11
With this code I manage to identify the cards that are attached and write the card number on the serial monitor:
#include <SoftwareSerial.h>
#include <PN532_SWHSU.h>
#include <PN532.h>
SoftwareSerial SWSerial(10, 11);
PN532_SWHSU pn532swhsu(SWSerial);
PN532 nfc(pn532swhsu);
void setup(void) {
Serial.begin(115200);
Serial.println("Hello Maker!");
nfc.begin();
uint32_t versiondata = nfc.getFirmwareVersion();
if (!versiondata) {
Serial.print("Didn't Find PN53x Module");
while (1);
}
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);
nfc.SAMConfig();
Serial.println("Waiting for an ISO14443A Card ...");
}
void loop(void) {
boolean success;
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };
uint8_t uidLength;
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, &uid[0], &uidLength);
if (success) {
Serial.println("Found A Card!");
Serial.print("UID Length: ");
Serial.print(uidLength, DEC);
Serial.println(" bytes");
Serial.print("UID Value: ");
for (uint8_t i = 0; i < uidLength; i++) {
Serial.print(uid[i], DEC);
}
Serial.println("");
}
How can I write data like for example "Victor=120" and read it again later from the chip?