monkeyboard / Wiegand-Protocol-Library-for-Arduino

Wiegand 26 and Wiegand 34 Protocol Library for Arduino
323 stars 131 forks source link

Wiegand.h not working on other pins than 2 & 3 #53

Closed StephaneCYB closed 3 years ago

StephaneCYB commented 3 years ago

Pin 2 is in our application used for the RS485 control, so I changed D0 to pin4 & D1 to pin5. This doesn't work (I'm using an Arduino Nano)

Any idea what I'm doing wrong?

include

WIEGAND wg; const int WG_D0 = 4; const int WG_D1 = 5;

void setup() { Serial.begin(9600);

// default Wiegand Pin 2 and Pin 3 see image on README.md // for non UNO board, use wg.begin(pinD0, pinD1) where pinD0 and pinD1 // are the pins connected to D0 and D1 of wiegand reader respectively. wg.begin(WG_D0,WG_D1); }

void loop() { if(wg.available()) { Serial.print("Wiegand HEX = "); Serial.print(wg.getCode(),HEX); Serial.print(", DECIMAL = "); Serial.print(wg.getCode()); Serial.print(", Type W"); Serial.println(wg.getWiegandType());
} }

monkeyboard commented 3 years ago

Arduino Nano that has ATmega328 only has two interrupt pins. This library will not work.

You might want to consider this library that is using PinChangeInterrupt https://github.com/jpliew/Multi-Reader-Wiegand-Protocol-Library-for-Arduino

Cheers

On Fri, 18 Jun 2021 at 19:53, StephaneCYB @.***> wrote:

Pin 2 is in our application used for the RS485 control, so I changed D0 to pin4 & D1 to pin5.

Any idea what I'm doing wrong?

include

WIEGAND wg; const int WG_D0 = 4; const int WG_D1 = 5;

void setup() { Serial.begin(9600);

// default Wiegand Pin 2 and Pin 3 see image on README.md // for non UNO board, use wg.begin(pinD0, pinD1) where pinD0 and pinD1 // are the pins connected to D0 and D1 of wiegand reader respectively. wg.begin(WG_D0,WG_D1); }

void loop() { if(wg.available()) { Serial.print("Wiegand HEX = "); Serial.print(wg.getCode(),HEX); Serial.print(", DECIMAL = "); Serial.print(wg.getCode()); Serial.print(", Type W"); Serial.println(wg.getWiegandType()); } }

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/monkeyboard/Wiegand-Protocol-Library-for-Arduino/issues/53, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAJPBY3ID27VE4E27TCOODDTTMJTJANCNFSM465LERAA .

StephaneCYB commented 3 years ago

Ok. Thank you ! Kind regards