Skip to content

Commit

Permalink
Create rfid.ino
Browse files Browse the repository at this point in the history
  • Loading branch information
quevon24 committed Sep 11, 2015
1 parent 4c50138 commit 00dfcd2
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions rfid/rfid.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
int val = 0;
char code[10];
int bytesread = 0;

void setup() {

Serial.begin(9600);
}


void loop() {

if(Serial.available() > 0) { // if data available from reader
if((val = Serial.read()) == 2) { // check for header
bytesread = 0;
while(bytesread<10) { // read 10 digit code
if( Serial.available() > 0) {
val = Serial.read();
if((val == 10)||(val == 13)) { // if header or stop bytes before the 10 digit reading
break; // stop reading
}
code[bytesread] = val; // add the digit
bytesread++; // ready to read next digit
}
}
if(bytesread == 10) { // if 10 digit read is complete
Serial.print("TAG code is: "); // possibly a good TAG
Serial.println(code); // print the TAG code
}
bytesread = 0;
}
}
}

0 comments on commit 00dfcd2

Please sign in to comment.