Created
April 6, 2015 20:19
-
-
Save jbdatko/194f697af3983fe7a8df to your computer and use it in GitHub Desktop.
RFID example for CryptoShield
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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