Shop OBEX P1 Docs P2 Docs Learn Events
RFID/Arduino Uno interfacing — Parallax Forums

RFID/Arduino Uno interfacing

89eliminator89eliminator Posts: 1
edited 2012-03-18 18:04 in Accessories
our team is currently working on a RFID based automatic door opener for our Senior Project. We have set the code and are reading the correct/incorrect key fobs correctly....some of the time. we have tried to manipulate the code in numerous ways and are completely out of ideas. is there anything that we are overlooking? anyone else come across this? i can get into more detail about the specific coding if necessary.

-Wade

Comments

  • GordonMcCombGordonMcComb Posts: 3,366
    edited 2012-03-18 18:04
    Which RFID product? The following example shows how to display codes using the RFID Card Reader Serial (product #28140). I don't have enough experience with the other RFID products to know if similar code will work. Beyond that, you should post the actual code you're using. If it's more than a few dozen lines, try to reduce it to its bare essentials, especially if the code involves interacting with other hardware.
    // Requires Arduino 1.0 IDE or later
    
    #include <SoftwareSerial.h>
    
    byte rxData = 0; 
    byte rfidBytes = 0;                       // Current index for buffer
    char rfidArray[10];                       // RFID buffer (10 bytes)
    
    #define Rx           7                    // SOUT pin
    #define Tx           255                  // No pin
    #define enable_pin   6                    // /ENABLE pin
    
    SoftwareSerial RFID = SoftwareSerial(Rx, Tx); 
    
    void setup() { 
      Serial.begin(9600);
      RFID.begin(2400);                       // Comm with reader
      pinMode(enable_pin, OUTPUT);            // Make enable pin an output
      delay(200);
    }
    
    void loop() { 
    
      if(RFID.available() > 0) {              // Check if reader is sending data 
        if((RFID.read()) == 0x0a) {           // Validate for header character
          rfidBytes = 0; 
          while(rfidBytes <= 10) {            // Get 10 bytes from reader
            if(RFID.available() > 0) { 
              rxData = RFID.read(); 
              rfidArray[rfidBytes++] = rxData;  // Collect 10 bytes into buffer           
            } 
          }
          Serial.print("ID: ");               // Print out RFID code
          Serial.println(rfidArray);
          digitalWrite(enable_pin, HIGH);     // Deactivate reader
          delay(1000);                        // 1 second delay
          RFID.flush(); 
          digitalWrite(enable_pin, LOW);      // Activate reader
        } 
      }
     
    } 
    

    -- Gordon
Sign In or Register to comment.