RFID to on / off LED

RFID reader, Reader/Writer, Tag.....

RFID to on / off LED

Postby mdshasha02 » Mon Apr 04, 2016 7:20 am

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!
mdshasha02
Fledgling
 
Posts: 1
Joined: Mon Apr 04, 2016 7:11 am

Re: RFID to on / off LED

Postby ober » Mon Apr 04, 2016 9:03 am

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.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm


Return to RFID

Who is online

Users browsing this forum: No registered users and 3 guests

cron