int card = 0; // int rfidstate = 0; int cardtimer = 0; void setup() { Serial.begin(9600); // Initialize serial monitor pinMode(A1,INPUT); // Connect FAST RFID reader data line to A1 input. Set A1 to digital input Serial.println("FAST RFID READER"); // Write this to the serial monitor } void loop() // The main loop simply acts to call the cardread() function over and over { cardread(); } void cardread() // This function acts to read cards, and to write card data to the serial monitor. So power up your arduino, load this code, and open the serial monitor. { card = 0; // Set int card to 0. rfidstate = 0; // Set rfid state to 0 while(digitalRead(A1) == LOW){ // Wait until card data on A1 line goes from 0v to 5v. Once there, this while loop will end. {} } while(rfidstate == 0){ // This new while loop will execute until rfidstate is more than 0 { while(digitalRead(A1) == HIGH){ // This new while loop will wait until the A1 line goes back to 0v from 1v. {} } card = card + 1; // Add 1 to card integer cardtimer = 0; // cardtimer integer set to 0; while(digitalRead(A1) == LOW){ // This while loop is a timer. It waits for A1 to go from 0v to 5v again. It counts pulses from the FAST rfid reader. { delay(1); // Wait 1ms cardtimer = cardtimer + 1; // Add 1 to cardtimer integer if(cardtimer > 7) // If cardtimer value is higher than 7 (7 ms has elapsed), then to do the following { if(card < 6) // If card value (Amount of incoming pulses) is less than 6 { Serial.print("Card#"); // Then write "Card#" to the serial monitor Serial.print(card); // Write card value Serial.println(" Detected!"); // Write "detected" rfidstate = 1; // rfidstate is changed to 1, which means that this function will end break; // Leave this while loop } else // If card is higher than 5, then do the following { Serial.println("Incorrect Card Detected!"); // Write to serial monitor "Incorrect Card Detected!' rfidstate = 1; // rfidstate is changed to 1, which means that this function will end break; // leave this while loop } } } } } } }