16x2 LCD Cannot Get Working With Sketch

I have been working all day with my LCD screen using a variety of sketches and its been fine. I have a Adafruit ADLX355 accelerometer sketch I’ve amended so it records the data to an sd card. Even with no lcd.print’s I get nothing but:

DDDDDDDDDDDDDDDDDDDDDDd…etc

This is without any lcd statements. As soon as I add a “test” print it makes no difference. Ive tried shutting everything off and resetting, etc.

Here is my code:

#include <SD.h>  //  Include SD library for the micro sd
#include <LiquidCrystal.h>

int CS_pin = 4;  //  SD chip select
int id = 1;  //  Set the ID for the beginning of .csv file.

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

const int xInput = A0;
const int yInput = A1;
const int zInput = A2;
const int buttonPin = 8;

// Raw Ranges:
// initialize to mid-range and allow calibration to
// find the minimum and maximum for each axis
int xRawMin = 512;
int xRawMax = 512;

int yRawMin = 512;
int yRawMax = 512;

int zRawMin = 512;
int zRawMax = 512;

// Take multiple samples to reduce noise
const int sampleSize = 10;

void setup() 
{
  lcd.begin(16, 2);
  analogReference(EXTERNAL);
  Serial.begin(9600);
  
  //  Check if card is ready
  if(!SD.begin(CS_pin)) {
    Serial.println("Card Failed");
    return;
  }
  Serial.println("Card Ready");
  
  //  Create a LOG.csv with headers
  File logFile = SD.open("LOG.csv", FILE_WRITE);
  if(logFile)
  {
    logFile.println(", , , ,");  //  Leave a blank line
    String header = "X, Y, Z";
    logFile.println(header);
    logFile.close();
    Serial.println(header);  //  Send to the serial monitor
  }
  else
  {
    Serial.println("Couldn't create LOG.csv file");
  }
}

void loop() 
{
  int xRaw = ReadAxis(xInput);
  int yRaw = ReadAxis(yInput);
  int zRaw = ReadAxis(zInput);
  
  if (digitalRead(buttonPin) == LOW)
  {
    AutoCalibrate(xRaw, yRaw, zRaw);
  }
  else
  {
    //Serial.print("Raw Ranges: X: ");
    //Serial.print(xRawMin);
    //Serial.print("-");
    //Serial.print(xRawMax);
    
    //Serial.print(", Y: ");
    //Serial.print(yRawMin);
    //Serial.print("-");
    //Serial.print(yRawMax);
    
    //Serial.print(", Z: ");
    //Serial.print(zRawMin);
    //Serial.print("-");
    //Serial.print(zRawMax);
    //Serial.println();
    //Serial.print(xRaw);
    //Serial.print(", ");
    //Serial.print(yRaw);
    //Serial.print(", ");
    //Serial.print(zRaw);
    
    // Convert raw values to 'milli-Gs"
    long xScaled = map(xRaw, xRawMin, xRawMax, -1000, 1000);
    long yScaled = map(yRaw, yRawMin, yRawMax, -1000, 1000);
    long zScaled = map(zRaw, zRawMin, zRawMax, -1000, 1000);
  
    // re-scale to fractional Gs
    float xAccel = xScaled / 1000.0;
    float yAccel = yScaled / 1000.0;
    float zAccel = zScaled / 1000.0;
  
   
   Serial.print("X: ");
   Serial.print(xAccel);
   Serial.print("  Y:");
   Serial.print(yAccel);
   Serial.print("  Z:");
   Serial.println(zAccel);
   
   File logFile = SD.open("LOG.csv", FILE_WRITE);
    if(logFile) 
    {
      logFile.print(xAccel);
      logFile.print(",");
      logFile.print(yAccel);
      logFile.print(",");
      logFile.println(zAccel);
      logFile.close();
      Serial.print(xAccel);
      Serial.print(",");
      Serial.print(yAccel);
      Serial.print(",");
      Serial.println(zAccel);
    }
    else
    {
      Serial.println("Couldn't open LOG.csv to write to file");
    }
    
  //  Lastly, increment the ID number
  id++;
  
  delay(2000);
  }
}

//
// Read "sampleSize" samples and report the average
//
int ReadAxis(int axisPin)
{
  long reading = 0;
  analogRead(axisPin);
  delay(1);
  for (int i = 0; i < sampleSize; i++)
  {
    reading += analogRead(axisPin);
  }
  return reading/sampleSize;
}

//
// Find the extreme raw readings from each axis
//
void AutoCalibrate(int xRaw, int yRaw, int zRaw)
{
  Serial.println("Calibrate");
  if (xRaw < xRawMin)
  {
    xRawMin = xRaw;
  }
  if (xRaw > xRawMax)
  {
    xRawMax = xRaw;
  }
  
  if (yRaw < yRawMin)
  {
    yRawMin = yRaw;
  }
  if (yRaw > yRawMax)
  {
    yRawMax = yRaw;
  }

  if (zRaw < zRawMin)
  {
    zRawMin = zRaw;
  }
  if (zRaw > zRawMax)
  {
    zRawMax = zRaw;
  }
}

Sorry, sorted the problem. It was a faulty switch for the calibration method which was why I could see any lcd.print test messages.