Interrupts - ARDUINO EXAMPLE
Interrupts - ARDUINO EXAMPLE
#include <Wiegand.h>
// Every few milliseconds, check for pending messages on the wiegand reader
// This executes with interruptions disabled, since the Wiegand library is not
thread-safe
void loop() {
noInterrupts();
wiegand.flush();
interrupts();
//Sleep a little -- this doesn't have to run very often.
delay(100);
}
// When any of the pins have changed, update the state of the wiegand library
void pinStateChanged() {
wiegand.setPin0State(digitalRead(PIN_D0));
wiegand.setPin1State(digitalRead(PIN_D1));
}