wiegand tests
This commit is contained in:
parent
57a6cdac5d
commit
cb6631d6cc
BIN
Wiegand-Protocol-Library-for-Arduino-1.0.20.zip
Normal file
BIN
Wiegand-Protocol-Library-for-Arduino-1.0.20.zip
Normal file
Binary file not shown.
61
wigandtest/wigand-test/wigand-test.ino
Normal file
61
wigandtest/wigand-test/wigand-test.ino
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
#include <Wiegand.h>
|
||||||
|
#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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user