Created
July 17, 2021 12:14
-
-
Save aleksul/f6194b7bc0cdda2acdcd9a039d8defbe to your computer and use it in GitHub Desktop.
Yet Another Wiegand Library minimum code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Wiegand.h> | |
// NOT a standart wiegand library | |
// Yet another wiegand library v2.0.0 by Paulo Costa | |
// https://github.com/paulo-raca/YetAnotherArduinoWiegandLibrary | |
#define PIN_D0 2 | |
#define PIN_D1 3 | |
Wiegand wg; | |
bool card_read_flag = false; | |
void setup() { | |
pinMode(PIN_D0, INPUT); | |
pinMode(PIN_D1, INPUT); | |
wg.onReceive(receivedData, ""); | |
wg.begin(26, true); | |
attachInterrupt(digitalPinToInterrupt(PIN_D0), pinStateChanged, CHANGE); | |
attachInterrupt(digitalPinToInterrupt(PIN_D1), pinStateChanged, CHANGE); | |
// Sends the initial pin state to the Wiegand library | |
pinStateChanged(); | |
} | |
void loop() { | |
if (card_read_flag) { | |
card_read_flag = false; | |
doSmth(); // your function | |
} | |
} | |
void receivedData(uint8_t* data, uint8_t bits, const char* message) { | |
card_read_flag = true; | |
for (int i=0; i < 3; i++) | |
massiv[i] = data[i]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment