Skip to content

Instantly share code, notes, and snippets.

@arkokoley
Created April 18, 2015 13:16
Show Gist options
  • Save arkokoley/977388eb8ebb7c2947b5 to your computer and use it in GitHub Desktop.
Save arkokoley/977388eb8ebb7c2947b5 to your computer and use it in GitHub Desktop.
Read RFID Tags via EM-18 RFID Reader
//ReadTag.ino
char input[12];
int count = 0;
void setup()
{
Serial.begin(9600);
}
void loop()
{
if(Serial.available())// check serial data ( RFID reader)
{
count = 0; // Reset the counter to zero
/* Keep reading Byte by Byte from the Buffer till the RFID Reader Buffer is empty
or till 12 Bytes (the ID size of our Tag) is read */
while(Serial.available() && count < 12)
{
input[count] = Serial.read(); // Read 1 Byte of data and store it in the input[] variable
count++; // increment counter
delay(5);
}
Serial.println("I received: ");
for(int i=0;i<10;i++)
Serial.print(input[i]);
Serial.println();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment