RFID Protected Mini-Fridgs (updated)

Can a mod please make this post #3

CODE PART 2

--

boolean checkTagForAuth(){
  boolean Auth1 = true;
  boolean Auth2 = true;

  Serial.println("AuthCheck is live");

  if(legit1[5] != tag[5]){
    Serial.println("We Failed checking the FIRST unique BYTE for LEGIT KEY 1"); 
  }

  if(legit2[5] != tag[5]){
    Serial.println("We Failed checking the FIRST unique BYTE for LEGIT KEY 2"); 
  }

  if(  (legit2[5] != tag[5]) && (legit1[5] != tag[5])){
    Serial.println("this should only happen if the tag is valid but not authed!!!! - SHOULD NOT SEE THIS");
  }

  for(int i=0; i<RFID_codeLength; i++) {
    // read each bit, see if it matches.  if not, reject it and set local auth to fail!
    if(legit1[i] != tag[i]){
      Auth1 = false;
      Serial.print(" (1) Failed on byte number ");
      Serial.println(i);
      break;  // DO NOT USE CONTINUE - we want to skip checking AS SOON AS WE FIND A SINGLE INVALID BYTE!
    }

  }

  for(int i=0; i<RFID_codeLength; i++) {
    // read each bit, see if it matches.  if not, reject it and set local auth to fail!
    if(legit2[i] != tag[i]){
      Auth2 = false;
      Serial.print(" (2) Failed on byte number ");
      Serial.println(i);
      break;  // DO NOT USE CONTINUE - we want to skip checking AS SOON AS WE FIND A SINGLE INVALID BYTE!
    }

  }

  if((Auth1=false) || (Auth2=false)){
    return false;
  } 
  else if((Auth1=true) || (Auth2=true)){
    return true;
  }

}

void Lock(int s){

  int pos = SERVO_Closed;  // temp for our position.
  Serial.println("LOCK IS LIVE and POINTER IS CLOSED");


  if(s == 1){
    // Lets LOCK
    Serial.println("Servo is now closing to LOCK");

    for(pos = SERVO_Open; pos >= SERVO_Closed; pos -= 1) {

      lock.write(pos);
      delay(SERVO_MiniDelay);
      Serial.println(pos);

    }


    Serial.println("servo should be closed now");

  } 
  else if(s == 0){

    // Lets OPEN - we assume it is locked
    Serial.println("Attempting to open");

    for(pos = SERVO_Closed; pos <= SERVO_Open; pos += 1) {

      lock.write(pos);
      delay(SERVO_MiniDelay);
      Serial.println(pos);

    }

    Serial.println("Servo should be open now!");

  }
}


void BlinkLED(int s){

  if(s ==1){
    digitalWrite(ledPin, HIGH);   // set the LED on
  }

  if(s == 0){
    digitalWrite(ledPin, LOW);   // set the LED off
  }  

}