Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- SoftwareSerial mySerial(9, 10); // mySerial(rx, tx);
- char val=0;
- void setup()
- {
- Serial.begin(9600);
- mySerial.begin(9600);
- }
- void loop(){
- mySerial.write(0xFE); //command flag
- mySerial.write(128); //position line 1
- delay(10); //wait 1ms
- mySerial.print("RFID TOKEN = ");
- digitalWrite (13, HIGH);//onboard LED to indicate ready state
- int tagString[13];
- int index = 0;
- boolean reading = false;
- while(Serial.available()){
- int readByte = Serial.read(); //read next available byte
- if(readByte == 2) reading = true; //begining of tag
- if(readByte == 3) reading = false; //end of tag
- if(reading && readByte != 2 && readByte != 10 && readByte != 13){
- //store the tag
- tagString[index] = readByte;
- index ++;
- }
- mySerial.write(0x7c);
- mySerial.write(0x1); //clear lcd
- mySerial.write(0xFE); //command flag
- mySerial.write(128); //position line 1
- delay(10); //wait 1ms
- mySerial.print("RFID TOKEN = ");
- mySerial.write(0xFE); //command flag
- mySerial.write(148); //position line 2
- // debug
- Serial.print("number of ints in tagString: ");
- Serial.println(index); // should hopefully be 13 (or 12 if i'm making an off by 1 error)
- for(int x=0;x<12;x++)
- {
- mySerial.print (tagString[x]);//write token to lcd
- Serial.println(tagString[x]);//write token to console
- delay(10);
- }
- // delay(10000);
- }
- }
Add Comment
Please, Sign In to add comment