Advertisement
mikroavr

wiegand_rfid

Mar 20th, 2024
591
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <Wiegand.h>
  2.  
  3. WIEGAND wg1;
  4. WIEGAND wg2;
  5. byte flag = 0;
  6.  
  7. void setup() {
  8.   Serial.begin(115200);
  9.  
  10.   // default Wiegand Pin 2 and Pin 3 see image on README.md
  11.   // for non UNO board, use wg.begin(pinD0, pinD1) where pinD0 and pinD1
  12.   // are the pins connected to D0 and D1 of wiegand reader respectively.
  13.   wg1.begin(32, 12);
  14.   wg1.begin(27, 13);
  15. }
  16.  
  17. void loop() {
  18.   if (wg1.available())
  19.   {
  20.     flag = 1;
  21.     Serial.print("Wiegand HEX = ");
  22.     Serial.print(wg1.getCode(), HEX);
  23.     Serial.print(", DECIMAL = ");
  24.     Serial.print(wg1.getCode());
  25.     Serial.print(", Type W");
  26.     Serial.println(wg1.getWiegandType());
  27.   }
  28.   if (wg2.available())
  29.   {
  30.     flag = 2;
  31.     Serial.print("Wiegand HEX = ");
  32.     Serial.print(wg2.getCode(), HEX);
  33.     Serial.print(", DECIMAL = ");
  34.     Serial.print(wg2.getCode());
  35.     Serial.print(", Type W");
  36.     Serial.println(wg2.getWiegandType());
  37.   }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement