Micro SD datalogger & LCD 16x2 display on Arduino Uno

I’m very new to Arduino but I’m trying to use it for a research project for school. I’m trying to record the resistance through a force sensitive resistor (FSR) on a micro sd card while also displaying that current resistance value on a 16x2 LCD screen.

I started at with these two attached diagrams, I used pin 10 instead of 4 for the sd card. I can get the LCD to display the resistance (and force with a calibration curve) on its own, but when I try to add the SD card & code, the LCD displays ‘ffffffffff’ or ‘333333’.

I think the problem has something to do with trying to use pins 11 & 12 for both the LCD and micro sd card, but I don’t know how else to set it up. Please help!!! Here is my current code;

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

const int chipSelect = 10;
const int FSR_PIN = A0; // Pin connected to FSR/resistor divider

// Measure the voltage at 5V and resistance of your 3.3k resistor, and enter
// their value's below:
const float VCC = 4.98; // Measured voltage of Ardunio 5V line
const float R_DIV = 3230.0; // Measured resistance of 3.3k resistor

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);


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

Serial.print("Initializing SD card...");
if (!SD.begin()) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");

pinMode(FSR_PIN, INPUT);
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print("Start");

}



void loop() {

int fsrADC = analogRead(FSR_PIN);
// If the FSR has no pressure, the resistance will be
// near infinite. So the voltage should be near 0.

File myFile;
myFile = SD.open("test.txt", FILE_WRITE);

if (fsrADC != 0) // If the analog reading is non-zero
{
    // Use ADC reading to calculate voltage:
float fsrV = fsrADC * VCC / 1023.0;  // Volts
    // Use voltage and static resistor value to 
    // calculate FSR resistance:
float fsrR = R_DIV * (VCC / fsrV - 1.0) / 1000; // kOhms
    // calculate weight based on calibration
float fsrW = 401.58 * (1 / (fsrR)) - 1.35; // lbs

    // print resistance & weight detected to LCD
lcd.print("R = " + String(fsrR) + " kOhms");
lcd.setCursor(0, 1);
lcd.print("W = " + String(fsrW) + " lbs");
    // print weight to monitor
Serial.println(String(fsrW));
myFile.println(String(fsrW));
myFile.close();

delay(500);
lcd.clear();
}
else
{
 //No pressure detected
lcd.print("No Resistance;");
lcd.setCursor(0, 1);
lcd.print("No Weight");
Serial.println("No Weight");
myFile.println("0");
myFile.close();

delay(500);
lcd.clear();
}

}

Please edit your post to add code tags, as described in the "How to use this forum" post.

polo12med:
I think the problem has something to do with trying to use pins 11 & 12 for both the LCD and micro sd card,

Indeed, so why on earth would you do that? You already know that pins 11,12 are for SPI bus, hence the SD card module being connected thereto.

You have control over the pins used, and you don’t have to delve into the library in order to do that. All you need do is change the lineLiquidCrystal lcd(12, 11, 5, 4, 3, 2); to something more sensible.
Since the first two are vacant, you might try 7,6,5,4,3,2. If you are not into analogue stuff, there is something to be said for using A0>A5, a handy group of six that are available for digital. Don’t ask why anybody would ever write code for an LCD using this library and connected to pins used for the SPI bus.

Thanks Nick_Pyner, it works!