You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
One reader works fine, but when trying to use 2 readers only one of them will print any output.
Attempted with modified advanced example because pin 4 can't be used as an interrupt.
`/*
Advanced HidProxWiegand usage example.
*/
#include <Arduino.h>
#include "HidProxWiegand.h"
#define PIN_RDR1_DATA0 2 // The pin to use for reader 1, DATA 0.
#define PIN_RDR1_DATA1 3 // The pin to use for reader 1, DATA 1.
#define PIN_RDR2_DATA0 5 // The pin to use for reader 2, DATA 0.
#define PIN_RDR2_DATA1 6 // The pin to use for reader 2, DATA 1.
// Callback for handling card reads from reader 1.
void cardRead1Handler(ProxReaderInfo* reader) {
Serial.print(F("Card read: "));
Serial.print(reader->facilityCode);
Serial.print(F(":"));
Serial.println(reader->cardCode);
// Here you can add logic to see if the card that was read was actually
// valid or whatever. For example: reading stored card numbers from EEPROM
// and looking for a match. Ideal for access control applications.
//
// This would also be where you would want to change state of the buzzer
// and LEDs on the reader.
//digitalWrite(PIN_RDR1_BUZZER, HIGH);
//digitalWrite(PIN_RDR1_RED_LED, LOW);
//digitalWrite(PIN_RDR1_GREEN_LED, HIGH);
//delay(500);
//digitalWrite(PIN_RDR1_BUZZER, LOW);
//digitalWrite(PIN_RDR1_GREEN_LED, LOW);
//digitalWrite(PIN_RDR1_RED_LED, HIGH);
Can't use 2 readers with example code.
One reader works fine, but when trying to use 2 readers only one of them will print any output.
Attempted with modified advanced example because pin 4 can't be used as an interrupt.
`/*
Advanced HidProxWiegand usage example.
*/
#include <Arduino.h>
#include "HidProxWiegand.h"
#define PIN_RDR1_DATA0 2 // The pin to use for reader 1, DATA 0.
#define PIN_RDR1_DATA1 3 // The pin to use for reader 1, DATA 1.
#define PIN_RDR2_DATA0 5 // The pin to use for reader 2, DATA 0.
#define PIN_RDR2_DATA1 6 // The pin to use for reader 2, DATA 1.
// Reader 1 outputs.
//#define PIN_RDR1_BUZZER 6
//#define PIN_RDR1_GREEN_LED 7
//#define PIN_RDR1_RED_LED 8
//Reader 2 outputs.
//#define PIN_RDR2_BUZZER 9
//#define PIN_RDR2_GREEN_LED 10
//#define PIN_RDR2_RED_LED 11
ProxReaderInfo* reader1; // Card reader 1.
ProxReaderInfo* reader2; // Card reader 2.
// Callback for handling card reads from reader 1.
void cardRead1Handler(ProxReaderInfo* reader) {
Serial.print(F("Card read: "));
Serial.print(reader->facilityCode);
Serial.print(F(":"));
Serial.println(reader->cardCode);
}
void cardRead2Handler(ProxReaderInfo* reader) {
Serial.print(F("Card read: "));
Serial.print(reader->facilityCode);
Serial.print(F(":"));
Serial.println(reader->cardCode);
}
// Handle interrupt for reader 1, DATA 0.
void handleInterrupt0() {
if (reader1 != NULL) {
reader1->ISR_Data0();
}
}
// Handle interrupt for reader 1, DATA 1.
void handleInterrupt1() {
if (reader1 != NULL) {
reader1->ISR_Data1();
}
}
// Handle interrupt for reader 2, DATA 0.
void handleInterrupt2() {
if (reader2 != NULL) {
reader2->ISR_Data0();
}
}
// Handle interrupt for reader 2, DATA 1.
void handleInterrupt3() {
if (reader2 != NULL) {
reader2->ISR_Data1();
}
}
void setup() {
Serial.begin(9600);
while (!Serial) {
delay(10);
}
}
void loop() {
// Process any cards that have been read.
HidProxWiegand.loop();
}`
The text was updated successfully, but these errors were encountered: