Control de flujos en Control de acceso

Hola,

Estoy usando una arduino uno, con un lector qr por serial + nfc module v1.1 por i2c y los 2 sistemas por separado funcionan correctamente, al integrarlos en un sketch prevalece siempre el rfid, es decir que hasta que no sucede un success en el rfid no consigo leer nada por serial.

La librería que he usado de rfid es la de la web elecfreaks y estoy casi seguro que el problema es de código pero asimilo como condicionar que lea un soporte, pase unos ms y lea el siguiente haciendo un bucle infinito. Me podríais ayudar?

Un saludo.

Comienza colocando los enlaces de las librerías (usando etiquetas), los enlaces de los códigos (usando etiquetas) si hacen faltan pero lo dudo y tu código unido.

Si no sabes como usar etiquetas lee las Normas del foro.

Estas son las etiquetas mas usadas.

Estas són las librería a usar, la de i2c y la del nfc de elecfreaks,

#include <Wire.h>
#include <Adafruit_NFCShield_I2C.h>

#define IRQ   (2)
#define RESET (3)  // Not connected by default on the NFC Shield

Adafruit_NFCShield_I2C nfc(IRQ, RESET);

El código utilice parte del ejemplo para SPI que tienen en su web
http://www.elecfreaks.com/store/nfcrfid-breakout-module-p-519.html

Void setup

void setup(void) {
  Serial.begin(9600);
  Serial.println("Hello!");

  nfc.begin();

  uint32_t versiondata = nfc.getFirmwareVersion();
  if (! versiondata) {
    Serial.print("Didn't find PN53x board");
    while (1); // halt
  }
  // Got ok data, print it out!
  Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & 0xFF, HEX); 
  Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & 0xFF, DEC); 
  Serial.print('.'); Serial.println((versiondata>>8) & 0xFF, DEC);
  
  // configure board to read RFID tags
  nfc.SAMConfig();
  
  Serial.println("Waiting for an ISO14443A Card ...");
}

Void loop

void loop(void) {
  leerBarcode();
  imprimirBarcode();
  comprobarBarcode();
  borrarBarcode();
  delay(100);
  leerProx();
}
 void leerProx(){                              //lectura rfid mifare classic
          uint8_t success;
          uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 };  // Buffer to store the returned UID
          uint8_t uidLength;                        // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
          int contador = 0;
          success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
            if (success) {
  
    Serial.println("Leyendo tarjeta.....");
    Serial.println("");
    if (uidLength == 4)
    {

      uint8_t keya[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
      success = nfc.mifareclassic_AuthenticateBlock(uid, uidLength,0, 0, keya);
    
      if (success)
      {
        int sector = 16;
     
        uint8_t data[16];
        success = nfc.mifareclassic_ReadDataBlock(0, data);
        if (success)
        {
         
          nfc.PrintHexChar(data, 16);
          Serial.println("");
          delay(1000);
        }
        else
        {
          Serial.println("Ooops ... unable to read the requested block.  Try another key?");
        }
      }
      
      else
      {
        Serial.println("Ooops ... authentication failed: Try another key?");
      }
    }
  }
        }

      void leerBarcode(){                 //Lectura de Código de Barras
       if (Serial.available()){ 
        for (int i=0; i < 7; i = i +1){
            bar[i] = Serial.read();
            
          } 
        } 
      }

      void comprobarBarcode(){            //Comprueba si coindicen los dígitos de control del Array con los del ticket 
        int prueba = 0;
        for (int i=0; i < 7; i = i+1){
            if (bar[i] == comprobar[i]){
            prueba = prueba +1;
          }
        }

        if (prueba == 7) {
            boolean correcto = false;
            Serial.println("Entrada correcta");
            Serial.println("                ");
            Serial.println("Abriendo puerta.... ");
            Serial.println("                ");
            correcto = true;
             if (correcto == true); {
                digitalWrite(opto, HIGH);
                delay(2000);
                digitalWrite(opto, LOW); }   
          }
      }
      
      void imprimirBarcode(){             //Impresión de Código de Barras
        for (int i = 0; i < 7; i = i+1) {
            Serial.print(bar[i]);
        }
        Serial.println();
      }

      void borrarBarcode(){               //Borrar memoria buffer barcode
        for (int i=0; i < limite; i++){
            bar[i] = 0;
     }     }

El programa se queda en espera en el sucess esperando una tarjeta de prox