支持 ESP8266。
This commit is contained in:
parent
4902704eb5
commit
ae2426f38f
@ -1,7 +1,7 @@
|
||||
#include "cmd.h"
|
||||
|
||||
#define SerialDevice SerialUSB //32u4,samd21
|
||||
//#define SerialDevice Serial
|
||||
//#define SerialDevice SerialUSB //32u4,samd21
|
||||
#define SerialDevice Serial //esp8266
|
||||
|
||||
void SerialCheck() {
|
||||
switch (packet_read()) {
|
||||
@ -59,7 +59,7 @@ void SerialCheck() {
|
||||
|
||||
void setup() {
|
||||
SerialDevice.begin(38400);
|
||||
// SerialUSB.begin(119200);//high_baudrate=true
|
||||
// SerialDevice.begin(119200);//high_baudrate=true
|
||||
SerialDevice.setTimeout(0);
|
||||
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
|
||||
nfc.begin();
|
||||
|
@ -21,7 +21,7 @@ Arduino 和 PN532 接好 VCC,GND,SDA,SCL;
|
||||
#### 已测试开发板:
|
||||
- SparkFun Pro Micro(ATmega32U4),需要发送 DTR/RTS
|
||||
- SparkFun SAMD21 Dev Breakout(ATSAMD21G18)
|
||||
- NodeMCU 1.0(ESP-12E + CP2102),SDA=D2,SCL=D1
|
||||
- NodeMCU 1.0(ESP-12E + CP2102 & CH340),SDA=D2,SCL=D1
|
||||
|
||||
#### 引用库:
|
||||
- [驱动WS2812B FastLED.h](https://github.com/FastLED/FastLED)
|
||||
|
2
cmd.h
2
cmd.h
@ -1,6 +1,6 @@
|
||||
#include "FastLED.h"
|
||||
#define NUM_LEDS 6
|
||||
#define DATA_PIN A3
|
||||
#define DATA_PIN D4
|
||||
#define BRI 50
|
||||
CRGB leds[NUM_LEDS];
|
||||
|
||||
|
@ -2,6 +2,9 @@
|
||||
#include <PN532_I2C.h>
|
||||
#include <PN532.h>
|
||||
|
||||
//#define SerialDevice SerialUSB //32u4,samd21
|
||||
#define SerialDevice Serial //esp8266
|
||||
|
||||
PN532_I2C pn532i2c(Wire);
|
||||
PN532 nfc(pn532i2c);
|
||||
|
||||
@ -23,12 +26,12 @@ uint8_t MifareKey[6] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
|
||||
#define M2F_B 1
|
||||
|
||||
void setup() {
|
||||
SerialUSB.begin(38400);
|
||||
SerialUSB.setTimeout(0);
|
||||
while (!SerialUSB);
|
||||
SerialDevice.begin(38400);
|
||||
SerialDevice.setTimeout(0);
|
||||
while (!SerialDevice);
|
||||
nfc.begin();
|
||||
while (!nfc.getFirmwareVersion()) {
|
||||
SerialUSB.println("Didn't find PN53x board");
|
||||
SerialDevice.println("Didn't find PN53x board");
|
||||
delay(2000);
|
||||
}
|
||||
nfc.setPassiveActivationRetries(0x10);
|
||||
@ -40,25 +43,25 @@ void loop() {
|
||||
delay(1000);
|
||||
|
||||
if (nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uL) && nfc.mifareclassic_AuthenticateBlock(uid, uL, 1, 1, AimeKey)) {
|
||||
SerialUSB.println("Aime");
|
||||
SerialDevice.println("Aime");
|
||||
return;
|
||||
}
|
||||
if (nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uL) && nfc.mifareclassic_AuthenticateBlock(uid, uL, 1, 0, BanaKey)) {
|
||||
SerialUSB.println("Bana");
|
||||
SerialDevice.println("Bana");
|
||||
return;
|
||||
}
|
||||
if (nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uL) && nfc.mifareclassic_AuthenticateBlock(uid, uL, M2F_B, 0, MifareKey)) {
|
||||
SerialUSB.println("Default Key Mifare");
|
||||
SerialDevice.println("Default Key Mifare");
|
||||
return;
|
||||
}
|
||||
if (nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uL)) {
|
||||
SerialUSB.println("Mifare:Unknown key");
|
||||
SerialDevice.println("Mifare:Unknown key");
|
||||
return;
|
||||
}
|
||||
|
||||
if (nfc.felica_Polling(systemCode, requestCode, card.IDm, card.PMm, &systemCodeResponse, 200)) {
|
||||
SerialUSB.println("Found a Felica card!");
|
||||
SerialDevice.println("Found a Felica card!");
|
||||
return;
|
||||
}
|
||||
SerialUSB.println("Didn't find card");
|
||||
SerialDevice.println("Didn't find card");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user