problem merging example programs for PN532 NFC and adafruit-sharpmemory LCD

The products and manuals can be found in the links below although the PN532 picture shows V2 I have version V3.

http://www.elechouse.com/elechouse/index.php?main_page=product_info&cPath=90_93&products_id=2242

http://www.elechouse.com/elechouse/images/product/PN532_module_V3/PN532_%20Manual_V3.pdf manual

https://github.com/elechouse/PN532 library files and example code

So to summarise I have the two example programs working separately with their respective hardware.
When I merge the programs and uncomment the single line shown below below the program wont find the reader PN532 . As the programs compile okay I assume I have all the relevant library files up to date.

Adafruit_SharpMem display(SCK, MOSI, SS);// uncommenting this line leads to the following error

after the ‘NDEF Reader’ text is displayed

‘Didn’t find PN53x board’
with line above commented I get the following message.

NDEF Reader
Found chip PN532
Firmware ver. 1.6

Scan a NFC tag

Scan a NFC tag…

I have spent two days 8 plus hours trialing different ideas/code from endless web researching pn532 SPI problems I have tried pullup resistors on the CS/SS pin on both
devices and I have moved the PN532 on to the I2C and HSU configuration and adjusted the respective configuration board switch, and altered the program to suit (line 13 #if 1>#if 0) I have tried arduino mini and UNO as

thats all I have at present. I Couldn’t get I2C to detect the card reader and HSU example code available as far as I could see was limited to serial number of NFC card and may be my last option.

As for the wiring the PN532 was wired as per the manual for spi i.e SCK= Pin D13 , MISO =pinD12, MOSI = pinD11 ,SS= Pin D10.

The Sharp memory display can be configured to almost any pins from the Adafruit web informaton, I did also tried commoning it up with pin D13 (SCK) pin D11(MOSI) and using D9 for CS instead of D10(as used by SS of PN532,. If you initialise it first as it gets disabled once the nfc.begin command is executed and vice versa the card reader doesnt get detected once the screen initialised.

The PN532 has the undetected error above as the line is uncommented to attempt to allow the display to work.

The Sharp memory display LCD Only requires 3 pins to work see code example.

I have a basic ability in developing / cobling Arduino code together over about 2 years on and off.

I’m trying to achieve reading a NFC tag card and displaying the record information on the LCD.
I can achieved both these tasks with using the example code I just want to put them on the same
Arduino if possible.

Ive looked at Gammon Forum : Electronics : Microprocessors : SPI - Serial Peripheral Interface - for Arduino tried things like…SPI.endTransaction()

apology if req for the above if I left something out and the above format, been up all nite dont no what I did but .

Here is the merged codes.

merged two examples sharpmemtest.ino and ReadTagExtended.ino and elininated non required code:
/*
wire up for the PN532 spi configuration
SCK Pin 13
MISO Pin 12
MOSI Pin 11
SS Pin 10

For the Adafruit Sharp memory display wire up
SCK 7 //was 10 in example program
MOSI 8 //was 11 in example program
SS 9 //was 13 in example program
*/
#if 1
//change to 1 for spi wired
#include <SPI.h>
#include <PN532_SPI.h>
#include <PN532.h>
#include <NfcAdapter.h>

PN532_SPI pn532spi(SPI, 10);
NfcAdapter nfc = NfcAdapter(pn532spi);
#else

#include <Wire.h>
#include <PN532_I2C.h>
#include <PN532.h>
#include <NfcAdapter.h>

PN532_I2C pn532_i2c(Wire);
NfcAdapter nfc = NfcAdapter(pn532_i2c);
#endif

#include <Adafruit_GFX.h>
#include <Adafruit_SharpMem.h>

#define SCK 7 //was 10 in example program
#define MOSI 8 //was 11 in example program
#define SS 9 //was 13 in example program
//#define SCK 13 //was 10 in example program
//#define MOSI 11 //was 11 in example program
//#define SS 9 //was 13 in example program

//Adafruit_SharpMem display(SCK, MOSI, SS);uncommenting this line leads to the following error
//‘Didn’t find PN53x board’

#define BLACK 0
#define WHITE 1

void setup(void) {
Serial.begin(9600);
//Uncomment this section below and the screen works at the beginning
//but the card reader doesnt initilise error and the error below appears
//prints this line okay NDEF Reader
// then shows message “Didn’t find PN53x board”
/*
// draw the first ~12 characters in the font
// testdrawchar();
display.refresh();
delay(2000);
display.clearDisplay();
// text display tests
display.setTextSize(1);
display.setTextColor(BLACK);
display.setCursor(0,0);
display.println(“Hello, world!”);
display.setTextColor(WHITE, BLACK); // ‘inverted’ text
display.println(3.141592);
display.setTextSize(2);
display.setTextColor(BLACK);
display.print(“0x”); display.println(0xDEADBEEF, HEX);
display.refresh();
delay(2000);

*/
Serial.println(“NDEF Reader”);

nfc.begin();
}

void loop(void) {
Serial.println(“nScan a NFC tagn”);

if (nfc.tagPresent())
{
NfcTag tag = nfc.read();
Serial.println(tag.getTagType());
Serial.print("UID: ");Serial.println(tag.getUidString());

if (tag.hasNdefMessage()) // every tag won’t have a message
{

NdefMessage message = tag.getNdefMessage();
Serial.print(“nThis NFC Tag contains an NDEF Message with “);
Serial.print(message.getRecordCount());
Serial.print(” NDEF Record”);
if (message.getRecordCount() != 1) {
Serial.print(“s”);
}
Serial.println(".");

// cycle through the records, printing some info from each
int recordCount = message.getRecordCount();
for (int i = 0; i < recordCount; i++)
{
Serial.print("nNDEF Record ");Serial.println(i+1);
NdefRecord record = message.getRecord(i);
// NdefRecord record = message*; // alternate syntax*

  • Serial.print(" TNF: ");Serial.println(record.getTnf());*
  • Serial.print(" Type: ");Serial.println(record.getType()); // will be “” for TNF_EMPTY*
  • // The TNF and Type should be used to determine how your application processes the payload*
  • // There’s no generic processing for the payload, it’s returned as a byte*
  • int payloadLength = record.getPayloadLength();*
  • byte payload[payloadLength];*
  • record.getPayload(payload);*
  • // Print the Hex and Printable Characters*
  • Serial.print(" Payload (HEX): ");*
  • PrintHexChar(payload, payloadLength);*
  • // Force the data into a String (might work depending on the content)*
  • // Real code should use smarter processing*
  • String payloadAsString = “”;*
  • for (int c = 0; c < payloadLength; c++) {*
  • payloadAsString += (char)payload*
    ```c
    *;
         }
         Serial.print("  Payload (as String): ");
         Serial.println(payloadAsString);

// id is probably blank and will return “”
     String uid = record.getId();
     if (uid != “”) {
       Serial.print("  ID: ");Serial.println(uid);
     }
   }

// draw the first ~12 characters in the font
//  testdrawchar();
/*
// this screen initilase doest work after nfc.begin but works before the line nfc.begin executes
display.refresh();
delay(2000);
display.clearDisplay();
// text display tests
display.setTextSize(1);
display.setTextColor(BLACK);
display.setCursor(0,0);
display.println(“Hello, world!”);
display.setTextColor(WHITE, BLACK); // ‘inverted’ text
display.println(3.141592);
display.setTextSize(2);
display.setTextColor(BLACK);
display.print(“0x”); display.println(0xDEADBEEF, HEX);
display.refresh();
delay(2000);

*/

}
}
delay(3000);
}*
```

Why are you posting in the Website and Forum section when your problem has nothing to do with the way this website works?

And please modify your post and use the code button </>

so your code looks like this

and is easy to copy to a text editor. See How to use the Forum Your code is too long for me to study quickly without copying to a text editor.

…R

Why are you posting in the Website and Forum section when your problem has nothing to do with the way this website works?

And please modify your post and use the code button </>

so your code looks like this

and is easy to copy to a text editor. See How to use the Forum Your code is too long for me to study quickly without copying to a text editor.

…R
[/quote]

The stupid reason I posted here was after a fair bit 30min plus of time looking at the very link ‘how to use this forum’ on the help I was unable to find the New Topic link where the guide suggested in the help guide ,honest . But now it appears to be there . It could of been the lack of sleep or I had done a login reset password and my new password hadnt filtered though of something access rights maybe if I wasnt properly logged on I had to reset the password again and remain with the default .
I will try to remove the post and repost but thanks for opening my eyes. Similarly for the code button couldnt see them . Sorry . Also I was unable to see how to reply here without quoting you.