Arduino with Adafruit NFC Shield restarts when removing tag too early

Hi guys! i am making an NFC project with the adafruit nfc reader (here). I have one problem though, if i scan a tag, and then remove it too early, it restarts my arduino. I think i have found something regarding the restart, but i am not that good at code yet, so i don't know why it restarts. I hope you can help me with this.

when i scan a tag to the nfc reader, the reader blinks. if i remove the tag, when it blinks (while it reads), the whole arduino restarts.

My code is attached as a .ino file, if you want any other filetype, i will upload it again. :slight_smile:

This is my Serial log:

ok
Entering reader
UID CHECK
UID
ReadPayLoad
er                        ok

So as you see, it prints "er" and then further out it prints "ok" which is the first thing it prints in the setup.

I suspect that the "er" comes from "err" which is from a library i use. it is used in the "NDEF.H" part of this library right here. It is on my personal dropbox, but you should be able to acess it. If you open the "ndef.h" file, you can search for "err" and it will pop right up.

It has to be right at the last second of the scan though. if i remove the tag almost instantly, it uses my "error" function properly, and the serial log ends like this:

Entering reader
ok
UID CHECK
UID
ReadPayLoad
err
ERROR
ERROR = 1
Reader Done!
Entering reader

I hope you guys are able to help me.
Thanks in advance.

-Kasper Røgen

Reader_Sound.ino (10.5 KB)

Noone is able to help me with this?

Noone is able to help me with this?

No one want to risk getting a virus accessing the site where you posted your code. Attach it here, if you want people to look at it.

If you're unsure about how to post code, start here

Ah, i see. I didn't even think about people seeing it as a possible virus. I just can't post my code here, because it is too long. I get a message from the site saying that. I will upload it onto here, though i don't see the difference. :slight_smile:

Thanks for the help guys. :slight_smile:

I just can't post my code here, because it is too long.

Sure you can. Click Reply. Don't use the worthless Quick Reply field. There is a link just below this window, Attachments and other options. I'm guessing you can figure it out from there.