TA的每日心情 | 郁闷 2013-6-3 09:22 |
---|
签到天数: 29 天 连续签到: 1 天 [LV.4]偶尔看看III
|
本帖最后由 pcduino 于 2013-4-18 10:44 编辑
PN532占用SPI会有相对较高的速度哦。
proto shield 配套的线太长了,我们最好用一根短的跳线连接 proto shield 和pcDuino,接线图如下:
github上有很多不同的演示代码,以下代码是读取 RFID卡的ID
- #A potion of the code was copied from:
- #https://github.com/adafruit/Adafruit-PN532
- #include
- #include "Serial.h"
- #include "PN532.h"
- #define SCK 13
- #define MOSI 11
- #define SS 10
- #define MISO 12
- PN532 nfc(SCK, MISO, MOSI, SS);
- void setup(void) {
- Serial.begin(9600);
- Serial.println("Hello!");
- nfc.begin();
- uint32_t versiondata = nfc.getFirmwareVersion();
- 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);
- Serial.print("Supports "); Serial.println(versiondata & 0xFF, HEX);
- // configure board to read RFID tags and cards
- nfc.SAMConfig();
- }
- void loop(void) {
- uint32_t id;
- // look for MiFare type cards
- id = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A);
- if (id != 0) {
- Serial.print("Read card #"); Serial.println(id);
- }
- }
复制代码 |
|