Skip to content

Instantly share code, notes, and snippets.

@jbdatko
Created April 6, 2015 20:19
Show Gist options
  • Save jbdatko/194f697af3983fe7a8df to your computer and use it in GitHub Desktop.
Save jbdatko/194f697af3983fe7a8df to your computer and use it in GitHub Desktop.
RFID example for CryptoShield
const int TAG_LENGTH = 13;
char tag[TAG_LENGTH + 2];
int index = 0;
void setup(){
Serial.begin(9600);
memset(tag, 0, sizeof(tag));
}
void loop(){
while(Serial.available()){
int readByte = Serial.read();
if (readByte == 0x02){
// Begining byte, just skip it
}
else if (readByte == 0x03)
{
//done reading, 0x03 is the end byte of the tag
delay(10);
Serial.write(tag);
//reset the buffer for the next tag
index = 0;
memset(tag, 0, sizeof(tag));
}
else {
tag[index] = readByte;
index += 1;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment