I need help
I make it works with the code below, but it's always checking id tags.. I want that the reader stay in stand-by if there is no card to scan, what i have to do?
#include "SoftwareSerial.h"
#define txPin 11
#define rxPin 10
SoftwareSerial RFID(rxPin, txPin);
int val=0;
byte data[5];
byte tag1[4] = {0x5E,0xE8,0xCB,0x61};
boolean tag1_card = true;
void setup(){
pinMode(txPin, OUTPUT);
pinMode(rxPin, INPUT);
pinMode(6,OUTPUT);
Serial.begin(9600);
RFID.begin(9600);
Serial.println("");
RFID.write(0xAB);
RFID.write(0x02);
RFID.write(0x02);
delay(100);
while(Serial.available()>0){
RFID.read();
}
Serial.println();
Serial.println("Waiting for Card...");
}
void loop() {
val = RFID.read();
Serial.println();
while (val != 0xAB){
val = RFID.read();
delay(10);
}
RFID.read();
RFID.read();
data[0] = RFID.read();
data[1] = RFID.read();
data[2] = RFID.read();
data[3] = RFID.read();
for (int i=0; i<4; i++){
if (data[i] < 16) Serial.print("0");
Serial.print(data[i], HEX);
if (data[i] != tag1[i]) {
tag1_card = false;
digitalWrite(6,LOW);
}
}
if (tag1_card) digitalWrite(6,HIGH);
RFID.write(0xAB);
RFID.write(0x02);
RFID.write(0x02);
}