upd example multireader

- comments
- reader info after init
- serial speed
This commit is contained in:
Rotzbua
2016-02-22 19:53:48 +01:00
parent 4dd8522a40
commit cd5bca80ad

View File

@@ -20,8 +20,8 @@
* Signal Pin Pin Pin Pin Pin Pin * Signal Pin Pin Pin Pin Pin Pin
* ----------------------------------------------------------------------------------------- * -----------------------------------------------------------------------------------------
* RST/Reset RST 9 5 D9 RESET/ICSP-5 RST * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST
* SPI SS 1 SDA(SS) 10 53 D10 10 10 * SPI SS 1 SDA(SS) ** custom, take a unused pin, only HIGH/LOW required **
* SPI SS 2 SDA(SS) 2 53 D10 10 10 * SPI SS 2 SDA(SS) ** custom, take a unused pin, only HIGH/LOW required **
* SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16 * SPI MOSI MOSI 11 / ICSP-4 51 D11 ICSP-4 16
* SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 * SPI MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14
* SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15 * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15
@@ -31,9 +31,9 @@
#include <SPI.h> #include <SPI.h>
#include <MFRC522.h> #include <MFRC522.h>
#define RST_PIN 10 // Configurable, see typical pin layout above #define RST_PIN 9 // Configurable, see typical pin layout above
#define SS_1_PIN 5 // Configurable, see typical pin layout above #define SS_1_PIN 10 // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 2
#define SS_2_PIN 3 // Configurable, see typical pin layout above #define SS_2_PIN 8 // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 1
#define NR_OF_READERS 2 #define NR_OF_READERS 2
@@ -46,13 +46,17 @@ MFRC522 mfrc522[NR_OF_READERS]; // Create MFRC522 instance.
*/ */
void setup() { void setup() {
Serial.begin(115200); // Initialize serial communications with the PC Serial.begin(9600); // Initialize serial communications with the PC
while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4) while (!Serial); // Do nothing if no serial port is opened (added for Arduinos based on ATMEGA32U4)
SPI.begin(); // Init SPI bus SPI.begin(); // Init SPI bus
for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) { for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) {
mfrc522[reader].PCD_Init(ssPins[reader], RST_PIN); // Init each MFRC522 card mfrc522[reader].PCD_Init(ssPins[reader], RST_PIN); // Init each MFRC522 card
Serial.print(F("Reader "));
Serial.print(reader);
Serial.print(F(": "));
mfrc522[reader].PCD_DumpVersionToSerial();
} }
} }
@@ -65,10 +69,10 @@ void loop() {
// Look for new cards // Look for new cards
if (mfrc522[reader].PICC_IsNewCardPresent() && mfrc522[reader].PICC_ReadCardSerial()) { if (mfrc522[reader].PICC_IsNewCardPresent() && mfrc522[reader].PICC_ReadCardSerial()) {
Serial.print(F("Reader: ")); Serial.print(F("Reader "));
Serial.print(reader); Serial.print(reader);
// Show some details of the PICC (that is: the tag/card) // Show some details of the PICC (that is: the tag/card)
Serial.print(F(" Card UID:")); Serial.print(F(": Card UID:"));
dump_byte_array(mfrc522[reader].uid.uidByte, mfrc522[reader].uid.size); dump_byte_array(mfrc522[reader].uid.uidByte, mfrc522[reader].uid.size);
Serial.println(); Serial.println();
Serial.print(F("PICC type: ")); Serial.print(F("PICC type: "));