Go Down

Topic: Use a "Master" badge to add new badges with HID/Arduino Mega 2560 (Read 107 times) previous topic - next topic

jtmiller

I have an HID reader attached to Arduino Mega2560. I am currently able to read a unique serial number for each badge I scan. I would like to be able to add/delete badge ID's using an established "Master" badge.

One option is two pushbuttons, one labeled "ADD" and one labeled "DELETE". If either of these are pressed when an established "Master" badge is scanned would execute the respective function on the very next badge scanned. I am also limited on space and won't have room for an LCD or display.

Ultimately I would like to be able to add/delete badges without using the Arduino IDE interface/programming. Any help or ideas would be greatly appreciated!

Code: [Select]
volatile unsigned long tagID = 0;
volatile unsigned long lastBitArrivalTime;
volatile int bitCount = 0;
int doorStrike = 10;

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

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

void setup()
{
  pinMode(doorStrike, OUTPUT);
  Serial.begin(9600);


  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);
    tagID = 0;
      bitCount = 0;
  }
      if (tagID == 183549979) //Arduino Bage ID}
    { digitalWrite(doorStrike, HIGH);
      delay(2000);
      digitalWrite(doorStrike, LOW);
    }
    if (tagID == 2459068932)//My Badge ID
    { digitalWrite(doorStrike, HIGH);
      delay(2000);
      digitalWrite(doorStrike, LOW);
    }
  }

ieee488

The only reason you'd add a badge is because it isn't in the "database".
You wouldn't need to delete a badge since it doesn't exist in the first place.

Scan Master; scan new badge.

The Arduino code takes action depending on whether the badge exists or not in its database.



jtmiller

Absolutely true on the add badge part.

On the delete badge part, there are situations where individuals would retain their badges for use in other areas but no longer be allowed access into one particular area.

Therefore I need a sustainable way for someone to delete a particular badge.

ieee488

That's not what you asked.
Because the DELETE button you mentioned isn't going to differentiate between "areas" whatever that they are.

jtmiller

My theory is, as flawed as it may be, is when a person is leaving the area and will no longer need access....

We press and hold the delete button
scan the master badge
scan the badge to delete
the code deletes the badge scanned (not the master)
release the delete button




Go Up