diff --git a/Wiegand-Protocol-Library-for-Arduino-1.0.20.zip b/Wiegand-Protocol-Library-for-Arduino-1.0.20.zip new file mode 100644 index 0000000..79afd48 Binary files /dev/null and b/Wiegand-Protocol-Library-for-Arduino-1.0.20.zip differ diff --git a/wigandtest/wigand-test/wigand-test.ino b/wigandtest/wigand-test/wigand-test.ino new file mode 100644 index 0000000..65319e8 --- /dev/null +++ b/wigandtest/wigand-test/wigand-test.ino @@ -0,0 +1,61 @@ +#include +#define LED_PIN 6 +#define BEEP_PIN 7 +WIEGAND wg; + +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. + pinMode(LED_PIN, OUTPUT); + pinMode(BEEP_PIN, OUTPUT); + + digitalWrite(LED_PIN, HIGH); // HIGH = off + digitalWrite(BEEP_PIN, HIGH); + + + Serial.println("asdf"); + wg.begin(); +} + +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()); + + switch(wg.getCode()) + { + case 1436321: + Serial.println("Pin Gris"); + grantAccessFeedback(); + break; + case 3336231: + Serial.println("Pin Azul"); + grantAccessFeedback(); + break; + default: + Serial.print("Desconosido: ");Serial.println(wg.getCode()); + } + + } + + // delay(3000); + // grantAccessFeedback(); +} + +void grantAccessFeedback() { + // Flash LED and beep + digitalWrite(LED_PIN, LOW); // LED on + // digitalWrite(BEEP_PIN, LOW); // Beep on + delay(5000); + // digitalWrite(BEEP_PIN, HIGH); // Beep off + delay(200); + digitalWrite(LED_PIN, HIGH); // LED off +} \ No newline at end of file