mbed code for the Kinoma team's wireless assignment
Dependencies: mbed
Fork of idd_hw5_kinoma_rememberkeys by
main.cpp
- Committer:
- smcqueen
- Date:
- 2014-11-09
- Revision:
- 0:372076a79d90
File content as of revision 0:372076a79d90:
#include "mbed.h" #include "Adafruit_PN532.h" #define SS PTD0 // PTD1 is also LED_BLUE, it will blink during SPI communication. #define SCK PTD1 #define MOSI PTD2 #define MISO PTD3 DigitalOut kinoma(D8); int previous = 0; Adafruit_PN532 nfc(SCK, MISO, MOSI, SS); void loop(void); int main() { kinoma = 0; nfc.begin(); uint32_t versiondata = nfc.getFirmwareVersion(); if (! versiondata) { while (1); // halt } nfc.SAMConfig(); while(1) { loop(); } } void loop(void) { uint8_t success; uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; uint8_t uidLength; success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength); if (success) { previous = 1; if (uidLength == 4) { uint8_t tag_1 = 250; uint8_t tag_2 = 186; uint8_t tag_3 = 106; uint8_t tag_4 = 10; kinoma = 1; } } else if (previous == 0){ kinoma = 0; } else { previous = 0; } }