Go Down

Topic: Proximity help? (Read 4 times) previous topic - next topic

johnwasser

OK.  The 6006B2B00 makes me think that you do have the Weigand model.

Connect 'data0' to pin 2 (interrupt 0) and 'data1' to pin 3 (interrupt 1).

Code: [Select]


volatile unsigned long tagID = 0;
volatile int bitCount = 0;

void ISRone(void)
{
  bitCount++;
  tagID <<= 1;
  tagID |= 1;
}

void ISRzero(void)
{
  bitCount++;
  tagID <<= 1;
}

void setup()
{
  Serial.begin(57600);

  pinMode(2, INPUT);
  digitalWrite(2, HIGH);  // Enable pull-up resistor
  attachInterrupt(0, ISRzero, FALLING);

  pinMode(3, INPUT);
  digitalWrite(3, HIGH);  // Enable pull-up resistor
  attachInterrupt(1, ISRone,  FALLING);

  tagID = 0;
  bitCount = 0;
}

void loop()
{
  if(bitCount >= 26)
    {
    Serial.println(tagID, HEX);
    tagID = 0;
    bitCount = 0;
  }
}
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

AKSoapy29

Alright. The serial port is all random. No two codes are alike. But it reads them. Now what?
Andrew K.

AKSoapy29

But if you scan the card and hit reset, it has the same code every time.
Andrew K.

johnwasser

Could be the code is not 26 bits.  Try this version:

Code: [Select]

volatile unsigned long tagID = 0;
volatile unsigned long lastBitArrivalTime;
volatile int bitCount = 0;

void ISRone(void)
{
  lastBitArrivalTime = millis();
  bitCount++;
  tagID <<= 1;
  tagID |= 1;
}

void ISRzero(void)
{
  lastBitArrivalTime = millis();
  bitCount++;
  tagID <<= 1;
}

void setup()
{
  Serial.begin(57600);

  pinMode(2, INPUT);
  digitalWrite(2, HIGH);  // Enable pull-up resistor
  attachInterrupt(0, ISRzero, FALLING);

  pinMode(3, INPUT);
  digitalWrite(3, HIGH);  // Enable pull-up resistor
  attachInterrupt(1, ISRone,  FALLING);

  tagID = 0;
  bitCount = 0;
}

void loop()
{
  //  See if it has been more than 1/4 second since the last bit arrived
  if(bitCount > 0 && millis() - lastBitArrivalTime >  250)
    {
    Serial.print(bitCount, DEC);
    Serial.print(" bits: ");
    Serial.println(tagID, HEX);
    tagID = 0;
    bitCount = 0;
  }
}
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

AKSoapy29

It also be me using power via USB. I'll try an altronix 12v power supply. My dad who works for VTI security suggested that.
Andrew K.

Go Up