user45213: For a school project, I'm using an Arduino Uno and a Parallax RFID together with some other components, I used a script I got from Instructables for reading my serial input from the RFID (link: http://www.instructables.com/id/Wiring-and-programming-the-Parallax-RFID-Serial-Ca/)
To use this serial data, you need to include an if loop in your loop function to check if the scanned tag equals the previous one. If it doesn't, the tag gets used further in the program. This doesn't allow scanning the same tag twice in a row. But I need that for my project. I have tried to work around it, but I can't seem to get it working, I always create a loop of unlimited scans or some other inregularities. Here's my code:
/* Libraries that need to be manually installed:
Blynk libraries: https://github.com/blynkkk/blynk-library/releases/download/v0.5.1/Blynk_Release_v0.5.1.zip
LiquidCrystal_I2C library: https://cdn.instructables.com/ORIG/FVH/K8OQ/J8UH0B9U/FVHK8OQJ8UH0B9U.zip
 */
#define BLYNK_PRINT Serial
#include <SoftwareSerial.h>
#include <BlynkSimpleShieldEsp8266.h>
#include <ESP8266_Lib.h>
#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
#include <Servo.h>
//#include <ThingSpeak.h>

//Setting up the Blynk wifi connection
#define ESP8266_BAUD 9600
char auth[] = "auth";

//Setting up the virtual pins
WidgetTerminal terminal(V1);
BLYNK_WRITE(V1){}
int freeSpots = 5;
BLYNK_READ(V2) 
{
  Blynk.virtualWrite(V2, freeSpots); 
}

//Setting up the RFID
#define RFIDEnablePin 8
#define RFIDSerialRate 2400 
String RFIDTAG=""; //Holds the RFID Code read from a tag
String DisplayTAG = ""; //Holds the last displayed RFID Tag

//Setting up the LCD
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

//Setting up the serial connection
SoftwareSerial EspSerial(2, 3);
ESP8266 wifi(&EspSerial);

//Setting up the servo
Servo slagboom;

//Tag database
char tags[7][5] = {"6196", "6753", "5655", "69EC", "9FFC"};
char owners[7][5] = {"per1", "per2", "per3", "per4", "per5"};
int statuses[7] ={0};

//unsigned long channelNumber = 461353;
//const char * APIKey = "IHFFREPE9XUNSN94";

void setup() {
  //Serial communication
  Serial.begin(RFIDSerialRate);
  EspSerial.begin(ESP8266_BAUD);
  //RFID pin setup
  pinMode(RFIDEnablePin,OUTPUT);
  digitalWrite(RFIDEnablePin, LOW);
  //Blynk startup
  Blynk.begin(auth, wifi, "ssid", "pass");
  //LCD startup
  lcd.begin(16,2);//16 kolommen, 2 rijen
  lcd.backlight();
  //Servo startup
  slagboom.attach(10);
  slagboom.write(35);

  //ThingSpeak.begin(client);

  //Blynk terminal printing test
  delay(1000);
  slagboom.detach();
  terminal.println(F("Terminal printing succesfull"));
  terminal.flush();

}

void loop() {
  if (Serial.available() > 0)
  {
    ReadSerial(RFIDTAG);
  }
  if (DisplayTAG != RFIDTAG)
  { 
    DisplayTAG=RFIDTAG;
    tagCompare(RFIDTAG);
  }
}


//Function for comparing the tag to the database
void tagCompare(String tagToCompare)
{
  char lastTag[5];
  tagToCompare.toCharArray(lastTag, 5);
  int i = 0;
  while (i < 5)
    {
      if (strcmp(tags[i], lastTag) == 0)
        {
          terminal.print(owners[i]);
          if (statuses[i] == 0)
          {
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("Welkom, ");
            lcd.setCursor(0,1);
            lcd.print(owners[i]);
            statuses[i] = 1;
            freeSpots--;
            digitalWrite(RFIDEnablePin, HIGH);
            slagboom.attach(10);
            slagboom.write(145);
            delay(1000);
            digitalWrite(RFIDEnablePin, LOW);
            slagboom.write(35);
            delay(500);
            slagboom.detach();
            terminal.println(F(" heeft de parking betreden."));
            terminal.flush();
          }
          else
          {
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("Tot ziens ");
            lcd.setCursor(0,1);
            lcd.print(owners[i]);
            statuses[i] = 0;
            freeSpots++;
            digitalWrite(RFIDEnablePin, HIGH);
            slagboom.attach(10);
            slagboom.write(145);
            delay(1000);
            digitalWrite(RFIDEnablePin, LOW);
            slagboom.write(35);
            delay(500);
            slagboom.detach();
            terminal.println(F(" heeft de parking verlaten."));
            terminal.flush();
          }
          //ThingSpeak.writeField(channelNumber, 1, i, APIKey);
          Blynk.run();
        }
      i++;
      }
  i = 0;
}

//Function for reading the tag 
void ReadSerial(String &ReadTagString)
{
  int bytesread = 0;
  int val = 0; 
  char code[10];
  String TagCode="";

  if(Serial.available() > 0)
  {  
    if((val = Serial.read()) == 10)
    {
      bytesread = 0; 
      while(bytesread<10) // Reads the tag code
      { 
        if( Serial.available() > 0) 
        { 
          val = Serial.read(); 
          if((val == 10)||(val == 13)) // If header or stop bytes before the 10 digit reading
          {  
            break; // Stop reading 
          } 
          code[bytesread] = val; // Add the digit 
          bytesread++; // Ready to read next digit 
        } 
      } 
      if(bytesread == 10)  // If 10 digit read is complete
      {
        for(int x=6;x<10;x++) //Copy the Chars to a String
        {
          TagCode += code[x];
        }
        ReadTagString = TagCode; //Returns the tag ID
        while(Serial.available() > 0) //Burn off any characters still in the buffer
        {
        Serial.read();
        }

      } 
      bytesread = 0;
      TagCode="";
    } 
  } 
}

Any help would be very much appreciated.
Thanks in advance.
Edit: here's the changes I made to the loop():
void loop() {
  if (Serial.available() > 0)
  {
    ReadSerial(RFIDTAG);
  }
  unsigned long millisScanned;
  if (DisplayTAG != RFIDTAG)
  { 
    DisplayTAG=RFIDTAG;
    tagCompare(RFIDTAG);
    millisScanned = millis();
  }
  unsigned long millisReference = millisScanned + 10000;
  if ((DisplayTAG == RFIDTAG) && (millis() >= millisReference))
  {
    tagCompare(RFIDTAG);
    millisScanned = millis();
  }
}


user27653: If you wish to allow even for duplicate scans, but only want to check it if the RFID reader returns a new scan string, then you don't even need millis()
void loop() {
  static bool pendingTag = false;
  if (Serial.available() > 0)
  {
    ReadSerial(RFIDTAG);
    pendingTag = true;   // Indicate that this is a new scan to check
  }
  if (pendingTag)
  {
    tagCompare(RFIDTAG);
    pendingTag = false;  // The tag is checked, no need to check again
    DisplayTAG=RFIDTAG;  // Not even sure if you use this anywhere else.
  }
}


45213: <p>For a school project, I'm using an Arduino Uno and a Parallax RFID together with some other components, I used a script I got from Instructables for reading my serial input from the RFID (link: <code>http://www.instructables.com/id/Wiring-and-programming-the-Parallax-RFID-Serial-Ca/</code>)
To use this serial data, you need to include an if loop in your loop function to check if the scanned tag equals the previous one. If it doesn't, the tag gets used further in the program. This doesn't allow scanning the same tag twice in a row. But I need that for my project. I have tried to work around it, but I can't seem to get it working, I always create a loop of unlimited scans or some other inregularities. Here's my code:</p>

<pre><code>/* Libraries that need to be manually installed:
Blynk libraries: https://github.com/blynkkk/blynk-library/releases/download/v0.5.1/Blynk_Release_v0.5.1.zip
LiquidCrystal_I2C library: https://cdn.instructables.com/ORIG/FVH/K8OQ/J8UH0B9U/FVHK8OQJ8UH0B9U.zip
 */
#define BLYNK_PRINT Serial
#include &lt;SoftwareSerial.h&gt;
#include &lt;BlynkSimpleShieldEsp8266.h&gt;
#include &lt;ESP8266_Lib.h&gt;
#include &lt;Wire.h&gt; 
#include &lt;LiquidCrystal_I2C.h&gt;
#include &lt;Servo.h&gt;
//#include &lt;ThingSpeak.h&gt;

//Setting up the Blynk wifi connection
#define ESP8266_BAUD 9600
char auth[] = "auth";

//Setting up the virtual pins
WidgetTerminal terminal(V1);
BLYNK_WRITE(V1){}
int freeSpots = 5;
BLYNK_READ(V2) 
{
  Blynk.virtualWrite(V2, freeSpots); 
}

//Setting up the RFID
#define RFIDEnablePin 8
#define RFIDSerialRate 2400 
String RFIDTAG=""; //Holds the RFID Code read from a tag
String DisplayTAG = ""; //Holds the last displayed RFID Tag

//Setting up the LCD
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);

//Setting up the serial connection
SoftwareSerial EspSerial(2, 3);
ESP8266 wifi(&amp;EspSerial);

//Setting up the servo
Servo slagboom;

//Tag database
char tags[7][5] = {"6196", "6753", "5655", "69EC", "9FFC"};
char owners[7][5] = {"per1", "per2", "per3", "per4", "per5"};
int statuses[7] ={0};

//unsigned long channelNumber = 461353;
//const char * APIKey = "IHFFREPE9XUNSN94";

void setup() {
  //Serial communication
  Serial.begin(RFIDSerialRate);
  EspSerial.begin(ESP8266_BAUD);
  //RFID pin setup
  pinMode(RFIDEnablePin,OUTPUT);
  digitalWrite(RFIDEnablePin, LOW);
  //Blynk startup
  Blynk.begin(auth, wifi, "ssid", "pass");
  //LCD startup
  lcd.begin(16,2);//16 kolommen, 2 rijen
  lcd.backlight();
  //Servo startup
  slagboom.attach(10);
  slagboom.write(35);

  //ThingSpeak.begin(client);

  //Blynk terminal printing test
  delay(1000);
  slagboom.detach();
  terminal.println(F("Terminal printing succesfull"));
  terminal.flush();

}

void loop() {
  if (Serial.available() &gt; 0)
  {
    ReadSerial(RFIDTAG);
  }
  if (DisplayTAG != RFIDTAG)
  { 
    DisplayTAG=RFIDTAG;
    tagCompare(RFIDTAG);
  }
}


//Function for comparing the tag to the database
void tagCompare(String tagToCompare)
{
  char lastTag[5];
  tagToCompare.toCharArray(lastTag, 5);
  int i = 0;
  while (i &lt; 5)
    {
      if (strcmp(tags[i], lastTag) == 0)
        {
          terminal.print(owners[i]);
          if (statuses[i] == 0)
          {
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("Welkom, ");
            lcd.setCursor(0,1);
            lcd.print(owners[i]);
            statuses[i] = 1;
            freeSpots--;
            digitalWrite(RFIDEnablePin, HIGH);
            slagboom.attach(10);
            slagboom.write(145);
            delay(1000);
            digitalWrite(RFIDEnablePin, LOW);
            slagboom.write(35);
            delay(500);
            slagboom.detach();
            terminal.println(F(" heeft de parking betreden."));
            terminal.flush();
          }
          else
          {
            lcd.clear();
            lcd.setCursor(0,0);
            lcd.print("Tot ziens ");
            lcd.setCursor(0,1);
            lcd.print(owners[i]);
            statuses[i] = 0;
            freeSpots++;
            digitalWrite(RFIDEnablePin, HIGH);
            slagboom.attach(10);
            slagboom.write(145);
            delay(1000);
            digitalWrite(RFIDEnablePin, LOW);
            slagboom.write(35);
            delay(500);
            slagboom.detach();
            terminal.println(F(" heeft de parking verlaten."));
            terminal.flush();
          }
          //ThingSpeak.writeField(channelNumber, 1, i, APIKey);
          Blynk.run();
        }
      i++;
      }
  i = 0;
}

//Function for reading the tag 
void ReadSerial(String &amp;ReadTagString)
{
  int bytesread = 0;
  int val = 0; 
  char code[10];
  String TagCode="";

  if(Serial.available() &gt; 0)
  {  
    if((val = Serial.read()) == 10)
    {
      bytesread = 0; 
      while(bytesread&lt;10) // Reads the tag code
      { 
        if( Serial.available() &gt; 0) 
        { 
          val = Serial.read(); 
          if((val == 10)||(val == 13)) // If header or stop bytes before the 10 digit reading
          {  
            break; // Stop reading 
          } 
          code[bytesread] = val; // Add the digit 
          bytesread++; // Ready to read next digit 
        } 
      } 
      if(bytesread == 10)  // If 10 digit read is complete
      {
        for(int x=6;x&lt;10;x++) //Copy the Chars to a String
        {
          TagCode += code[x];
        }
        ReadTagString = TagCode; //Returns the tag ID
        while(Serial.available() &gt; 0) //Burn off any characters still in the buffer
        {
        Serial.read();
        }

      } 
      bytesread = 0;
      TagCode="";
    } 
  } 
}
</code></pre>

<p>Any help would be very much appreciated.
Thanks in advance.</p>

<p>Edit: here's the changes I made to the loop():</p>

<pre><code>void loop() {
  if (Serial.available() &gt; 0)
  {
    ReadSerial(RFIDTAG);
  }
  unsigned long millisScanned;
  if (DisplayTAG != RFIDTAG)
  { 
    DisplayTAG=RFIDTAG;
    tagCompare(RFIDTAG);
    millisScanned = millis();
  }
  unsigned long millisReference = millisScanned + 10000;
  if ((DisplayTAG == RFIDTAG) &amp;&amp; (millis() &gt;= millisReference))
  {
    tagCompare(RFIDTAG);
    millisScanned = millis();
  }
}
</code></pre>
 27653: <p>If you wish to allow even for duplicate scans, but only want to check it if the RFID reader returns a new scan string, then you don't even need <code>millis()</code></p>

<pre><code>void loop() {
  static bool pendingTag = false;
  if (Serial.available() &gt; 0)
  {
    ReadSerial(RFIDTAG);
    pendingTag = true;   // Indicate that this is a new scan to check
  }
  if (pendingTag)
  {
    tagCompare(RFIDTAG);
    pendingTag = false;  // The tag is checked, no need to check again
    DisplayTAG=RFIDTAG;  // Not even sure if you use this anywhere else.
  }
}
</code></pre>
