From ae2426f38f94f09e18c4d6ba63ea75612cc4c633 Mon Sep 17 00:00:00 2001 From: Sucareto <28331534+Sucareto@users.noreply.github.com> Date: Mon, 9 Aug 2021 19:59:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=20ESP8266=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Arduino-Aime-Reader.ino | 6 +++--- README.md | 2 +- cmd.h | 2 +- tools/ReaderTest.ino | 23 +++++++++++++---------- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/Arduino-Aime-Reader.ino b/Arduino-Aime-Reader.ino index 5026d3e..e573bf4 100644 --- a/Arduino-Aime-Reader.ino +++ b/Arduino-Aime-Reader.ino @@ -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(leds, NUM_LEDS); nfc.begin(); diff --git a/README.md b/README.md index 454dfa5..ba20ab1 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/cmd.h b/cmd.h index 2c323d7..55153d0 100644 --- a/cmd.h +++ b/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]; diff --git a/tools/ReaderTest.ino b/tools/ReaderTest.ino index 211dee1..8a612dd 100644 --- a/tools/ReaderTest.ino +++ b/tools/ReaderTest.ino @@ -2,6 +2,9 @@ #include #include +//#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"); }