Use Seeeduino Arch (or Arch Pro) + NFC Shield to write a Mifare Classic tag

Dependencies:   PN532 USBDevice mbed

Revision:
3:59afaef9fb24
Parent:
2:56402cae2c3c
--- a/main.cpp	Thu Nov 21 06:31:29 2013 +0000
+++ b/main.cpp	Thu Nov 21 06:52:36 2013 +0000
@@ -2,38 +2,40 @@
 #include "PN532_SPI.h"
 #include "NfcAdapter.h"
 
-#define LOG(args...)        pc.printf(args)
-
-#if 0                           // Using Seeeduino Arch
-#include "USBSerial.h"
-USBSerial pc;
+#if 1                           // Using Seeeduino Arch
+#define LOG(args...)
 SPI spi(P1_22, P1_21, P1_20);  // SPI(mosi, miso, clk)
-PN532_SPI pn532spi(spi, P0_2)
+PN532_SPI pn532spi(spi, P0_2);
 
 #else                           // Using Arch Pro
+#define LOG(args...)        pc.printf(args)
 Serial pc(USBTX, USBRX);
 SPI spi(P0_18, P0_17, P0_15);
 PN532_SPI pn532spi(spi, P0_6);
 #endif
 
 NfcAdapter nfc(pn532spi);
-DigitalOut led(LED1);
-
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
 
 int main() {
+    led1 = 1;
+    LOG("NFC Writer\n");
     nfc.begin();
     while (1) {
+        LOG("\nPlace a formatted Mifare Classic NFC tag on the reader.");
         if (nfc.tagPresent()) {
+            led2 = 1;
             NdefMessage message = NdefMessage();
             message.addUriRecord("http://seeedstudio.com");
-    
             bool success = nfc.write(message);
             if (success) {
                 LOG("Success. Try reading this tag with your phone.");        
             } else {
                 LOG("Write failed.");
             }
+            led2 = 0;
         }
-        wait(6);
+        wait(5);
     }
 }