#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 }