From cd5bca80ad181be9051b6b29b862023cc8ec9442 Mon Sep 17 00:00:00 2001 From: Rotzbua Date: Mon, 22 Feb 2016 19:53:48 +0100 Subject: [PATCH] upd example multireader - comments - reader info after init - serial speed --- .../ReadUidMultiReader/ReadUidMultiReader.ino | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/examples/ReadUidMultiReader/ReadUidMultiReader.ino b/examples/ReadUidMultiReader/ReadUidMultiReader.ino index e81d657..bff028e 100644 --- a/examples/ReadUidMultiReader/ReadUidMultiReader.ino +++ b/examples/ReadUidMultiReader/ReadUidMultiReader.ino @@ -20,8 +20,8 @@ * Signal Pin Pin Pin Pin Pin Pin * ----------------------------------------------------------------------------------------- * RST/Reset RST 9 5 D9 RESET/ICSP-5 RST - * SPI SS 1 SDA(SS) 10 53 D10 10 10 - * SPI SS 2 SDA(SS) 2 53 D10 10 10 + * SPI SS 1 SDA(SS) ** custom, take a unused pin, only HIGH/LOW required ** + * 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 MISO MISO 12 / ICSP-1 50 D12 ICSP-1 14 * SPI SCK SCK 13 / ICSP-3 52 D13 ICSP-3 15 @@ -31,9 +31,9 @@ #include #include -#define RST_PIN 10 // Configurable, see typical pin layout above -#define SS_1_PIN 5 // Configurable, see typical pin layout above -#define SS_2_PIN 3 // Configurable, see typical pin layout above +#define RST_PIN 9 // 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 8 // Configurable, take a unused pin, only HIGH/LOW required, must be diffrent to SS 1 #define NR_OF_READERS 2 @@ -46,13 +46,17 @@ MFRC522 mfrc522[NR_OF_READERS]; // Create MFRC522 instance. */ 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) SPI.begin(); // Init SPI bus for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) { 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(); } } @@ -61,14 +65,14 @@ void setup() { */ void loop() { - for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) { + for (uint8_t reader = 0; reader < NR_OF_READERS; reader++) { // Look for new cards if (mfrc522[reader].PICC_IsNewCardPresent() && mfrc522[reader].PICC_ReadCardSerial()) { - Serial.print(F("Reader: ")); + Serial.print(F("Reader ")); Serial.print(reader); // 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); Serial.println(); Serial.print(F("PICC type: "));