Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an Arduino Mega2560 ref3 ADK which is connect to Android. I also have a seeed studio NFC shield connected to it.

The problem is that if I try to initialise the AndroidAccessory library and the PN532 library in the same sketch, it doesn't work. If I try to run my sketches separately it does work.

I believe that these two libraries are not compatible.

Does anyone have an idea what the problem may be?

share|improve this question
What is the electronics question? – Brian Carlton Nov 14 '12 at 18:21

The SeeedStudio NFC shield uses SPI to communicate with the Arduino. One simple option is to take the shield off the Arduino, wire up an alternative set of pins on the Arduino Mega for bit-banging SPI through, and verify whether conflicts still remain.

I am not familiar with the AndroidAccessory library, but if this library initializes or uses the pins used for SPI by the PN532 library for any reason, or is using SPI for some purpose, the library may conflict with the NFC Shield.

One might attempt to change the sequence of initialization calls of the two libraries, in case one or the other library is doing some blanket initialization that overrides some pin settings and impacts the other.

To investigate this further, one would have to examine the code or documentation of the Android Accessory library. The PN532 library is relatively simple, so checking through its code is not too messy.

Another potential issue might be insufficient memory for both libraries to operate simultaneously - less likely on the Mega 2560 than on the smaller microcontroller of the Arduino Uno for instance.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.