Page 1 of 1

RFID to on / off LED

PostPosted: Mon Apr 04, 2016 7:20 am
by mdshasha02
Hi there, I need some help with my program.i am using the mifare rc522 classic board with three tags. I wish to use them to detect / undetect items. I am able to turn on LED with first time tag but cannot off LED for second time tag. This is to show when the item is in, LED on.When the item is out, LED off. My codings are as follows:

//First item
if(str[0] == 181) //First card ID = 181
{
count = count ++;
Serial.print("Item Found: Book\n"); // Serial out
digitalWrite(6, HIGH); // Buzzer on
delay(200);
digitalWrite(6, LOW); //Buzzer off
digitalWrite(7, HIGH); //LED on


}
if(str[0] == 181 && count == 2 ) // First card ID = 181
{
Serial.print("Item out: Book\n"); // Serial Out
digitalWrite(6, HIGH); // Buzzer on
delay(200);
digitalWrite(6, LOW); //Buzzer off
digitalWrite(7, LOW); //LED off
count =0;

}

I do hope I can get some help here, I think I need to use some sort of maths or boolean feature to initiate count. Any help is much appreciated..thank you!

Re: RFID to on / off LED

PostPosted: Mon Apr 04, 2016 9:03 am
by ober
We do not have the Mifare rc522 to verify the program. But a brief look at the code, my suggestion would be:

count++; itself will increase by 1 and keep the value, you do not need count = count ++;

Since you are printing message to serial, why don you print the count too? and check the count value as you scan the card.