NOKIA LCD 5110 and SD card

I am currently struggling to get a Nokia LCD 5110 and a SD-card reader to work together.
I am using rinkydink LCD graph
and the standard arduino SD and SPI library.

Using an arduino nano.

I have setup my pins correctly from what i can tell, the LCD chip select is wired to Digital 4 of my arduino and the SD card reader to digital 7,

If I init the LCD and print something to the LCD then everything is as expected - but when i then use SD.begin() and nothing more SD related - all further LCD actions do nothing -

#include <LCD5110_Graph.h>
#include <SPI.h>
#include <SD.h>

LCD5110 myGLCD(13,11,3,5,4);

Sd2Card card;

const int select_sd = 7;
const int select_lcd = 4;


extern unsigned char SmallFont[];

void setup(){
  Serial.begin(9600);

  myGLCD.InitLCD();
  myGLCD.setFont(SmallFont);
  myGLCD.clrScr(); //Clearing screen
  myGLCD.print("Hello World",0, 0);
  myGLCD.update(); //works as expected, prints hello world at 0,0
  

  if (!card.init(SPI_QUARTER_SPEED, select_sd)) {
    Serial.println("initialization failed. Things to check:");
    Serial.println("* is a card inserted?");
    Serial.println("* is your wiring correct?");
    Serial.println("* did you change the chipSelect pin to match your shield or module?");
    return;
  } else {
    Serial.println("Wiring is correct and a card is present.");
  }
  //prints Wiring is correct and a card is present as expected.

  myGLCD.clrScr(); //Clearing screen
  myGLCD.print("Goodbye World",0, 0);
  myGLCD.update(); // Does nothing.
}

I've read this can be due to one library using SPI software and another using SPI hardware
Also tried to set the select pins to HIGH when not in use.

Anyone capable of helping me ?

Generally, SD card shield uses pin 4 for Chip Select.

So you have conflict with the library for the SD card and the LCD.

it is not a shield, sorry should have specified - the description is 'SD / Micro SD card breakout module'
it is 5V and 3.3V capable and has the following pins :
GND - GND
DO(MISO) - 12
CLK - 13
DI (MOSI) - 11
CS - Digital 7
VCC - 3.3V

The LCD has :
RST - Digtal 5
CE(CS) - Digital 4
DC - Digital 3
DIN(MOSI) - 11
CLK - 13
VCC - 3.3V
BL - VCC
GND - GND

My Code to test this setup is as follows :

// include the SD library:
#include <SPI.h>
#include <SD.h>

// set up variables using the SD utility library functions:
Sd2Card card;

//rinkydink graph nokia 5110 library :
#include <LCD5110_Graph.h>
//initialize with relevant pins, last number is CS
LCD5110 myGLCD(13,11,3,5,4);

extern unsigned char SmallFont[];

const int select_sd = 7;
const int select_lcd = 4;


void setup() {
  myGLCD.InitLCD();
  myGLCD.setFont(SmallFont);
  myGLCD.clrScr(); //Clearing screen
  delay(500);
  myGLCD.print("Hello",0,0);
  myGLCD.update(); //Updating the LCD
  
  SD.begin(select_sd); //comment out this to let 'Bye' print...

  myGLCD.print("Bye",0,10); //if SD is used then this does nothing.
  myGLCD.update(); //Updating the LCD
}

I've also experimented with clock speeds :
SD.begin(SPI_QUARTER_SPEED,sd_select); // alternative to test if clock speed was issue.

and doing

//...usual code up to SD.begin call

digitalWrite(select_sd,HIGH);
digitalWrite(select_lcd,LOW); //select the lcd.

myGLCD.print("Bye",0,10);

So LCD works okay alone?

What about the SD ? Does it work if you don't include the LCD part?

.

about lcd graph library :

This library uses an SPI-like software protocol and does require exclusive access to the pins used. You will not be able to share pins with other SPI devices.

elektrax:
about lcd graph library :

This library uses an SPI-like software protocol and does require exclusive access to the pins used. You will not be able to share pins with other SPI devices.

well how did i not notice that ...

I used rinky dink library as adafruit was not working for me for bitmaps.

Switched to adafruit and the issue persists, if i use the adafruit software init or hardware init it still persists.

found this thread
https://forum.arduino.cc/index.php?topic=53843.0

It talks of the same issues as me but i see its from 2011 and further adafruit LCD8544 now has both software SPI and hardware SPI support. or am i wrong?

ieee488:
So LCD works okay alone?

What about the SD ? Does it work if you don't include the LCD part?

.

If i use just lcd then all is fine, if i use just SD then SD is fine. both seem to not work together.

..another MISO conflict. Most SD-modules out there doesn't release MISO.
U'll find a hardware fix it the forum.
se this