Skip to content

Instantly share code, notes, and snippets.

@quantum-x
Created April 29, 2014 14:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quantum-x/b2233bd4102a959493c1 to your computer and use it in GitHub Desktop.
Save quantum-x/b2233bd4102a959493c1 to your computer and use it in GitHub Desktop.
// This #include statement was automatically added by the Spark IDE.
#include "nfc.h"
NFC_Module nfc;
void setup(void)
{
pinMode(D7,OUTPUT); // Turn on the D7 led so we know it's time
digitalWrite(D7,HIGH); // to open the Serial Terminal.
Serial.begin(9600); // Open serial over USB.
while(!Serial.available()) // Wait here until the user presses ENTER
SPARK_WLAN_Loop(); // in the Serial Terminal. Call the BG Tasks
// while we are hanging around doing nothing.
digitalWrite(D7,LOW); // Turn off the D7 led ... your serial is serializing!
nfc.begin();
Serial.println("MF1S50 Reader Demo From Elechouse!");
uint32_t versiondata = nfc.get_version();
//if (! versiondata) {
// Serial.print("Didn't find PN53x board");
// while (1); // halt
// }
// 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);
/** Set normal mode, and disable SAM */
nfc.SAMConfiguration();
}
void loop(void)
{
u8 buf[16],sta;
/** Polling the mifar card, buf[0] is the length of the UID */
sta = nfc.InListPassiveTarget(buf);
/** check state and UID length */
if(sta && buf[0] == 4){
/** the card may be Mifare Classic card, try to read the block */
Serial.print("UUID length:");
Serial.print(buf[0], DEC);
Serial.println();
Serial.print("UUID:");
}
}
@quantum-x
Copy link
Author

When I fire up the SC and drop into USB serial debugging, I get:

MF1S50 Reader Demo From Elechouse!
Didn't find PN53x board.

Using the Elechouse board, SCL to D1, SDA to D0, with pull up resistors - http://i.imgur.com/3sRFtIP.jpg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment