i am working with arduino and EM-18 Reader module. i have a code for reading different cards. But,it reads the card once and return the card data. i want to read the same card continuously or periodically using that module to detect the presence of the card on the reader module to do a specific task. simply, i want to get a high signal on a pin as long as there is a right a right card in the reader range .and the signal should be low if the card is away from the range of the reader.
i have a code to read a card. for the operation that i mentioned above, what changes should i make in that code . or please provide a proper code. please Help !!!!!
char input[12];
int Number;
void setup() {
Serial.begin(9600);
}
void loop() {
if(Serial.available())
{
int count = 0;
while(Serial.available() && count < 12)
{
input[count] = Serial.read();
count++;
delay(5);
}
if(input[0] == '6' && input[1] == 'D' && input[2] == '0' && input[3] == '0' &&
input[4] == '9' && input[5] == '4' && input[6] == 'D' && input[7] == '4' &&
input[8] == '8' && input[9] == '1' && input[10] == 'A' && input[11] == 'C' ) //if the card id read is 6D0094D481AC
{
Number=1;
Serial.println("GROUP 1");
}
else if(input[0] == '6' && input[1] == 'D' && input[2] == '0' && input[3] == '0' &&
input[4] == '9' && input[5] == '4' && input[6] == 'D' && input[7] == '6' &&
input[8] == 'F' && input[9] == 'F' && input[10] == 'D' && input[11] == '0' ) //if the read card id is 6D0094D6FFD0
{
Number=2;
Serial.println("GROUP 2");
}
else if(input[0] == '6' && input[1] == 'D' && input[2] == '0' && input[3] == '0' &&
input[4] == '9' && input[5] == '4' && input[6] == '9' && input[7] == 'C' &&
input[8] == 'B' && input[9] == 'B' && input[10] == 'D' && input[11] == 'E' )
{
Number=3;
Serial.println("GROUP 3");
}
else if(input[0] == '6' && input[1] == 'D' && input[2] == '0' && input[3] == '0' &&
input[4] == '9' && input[5] == '4' && input[6] == 'B' && input[7] == '5' &&
input[8] == 'E' && input[9] == 'B' && input[10] == 'A' && input[11] == '7' )
{
Number=4;
Serial.println("GROUP 4");
}
else if(input[0] == '6' && input[1] == 'D' && input[2] == '0' && input[3] == '0' &&
input[4] == '9' && input[5] == '4' && input[6] == 'C' && input[7] == '0' &&
input[8] == '2' && input[9] == '3' && input[10] == '1' && input[11] == 'A' )
{
Number=5;
Serial.println("GROUP 5");
}
}
}
please Help