I am working on a project and I need your help :o !
I am using 1 aruino UNO, 1 Rfid rc522, 1 dfplayer, 1neopixel ring and 1 rfid tag.
Every time I swipe the tag on the reader I want to trigger different function.
For instance:
1st swipe - light up the neopixel ring in green color and play music file 3
2nd swipe - light up the neopixel ring in red color and play music file 5
....etc.
The thing is I am not sure how should I make the reader understand that the same tag(UID) should trigger different functions.
This is the code that I am working on and my attempt to make this happen but doesn't work ( file name 1st attempt). when it reads the tag it plays song 1 for instance , then when it reads it again plays song 2 but afterwards it plays only the song 1 when it reads the tag
At the file "initial code" it is a simple version of the code without trying to trigger different function with the same tag.
Any kind of help will be super valuable!! Thank you
There is NO excuse for returning when no tag is present. The code should do something only when a tag is present. I suggest that you start over, and write the code properly.
There is NO reason to convert the tag data to a String. Or even a string.
The byte array of tag data matches some byte array of valid data, or it doesn't. memcmp() will answer that question.
EVERY { goes on a line BY ITSELF.
EVERY } goes on a line BY ITSELF.
You never count the number of times the card is presented, so you are going to have a very difficult time performing different action the first time, the second time, the third time, etc.
Why you DO do when the card is presented should be to call a function. Have different functions for the first time, the second time, etc.
Put the LED and music handling code in that function, NOT in loop().