LCD Issue Displaying on 2nd Line

Hi all! Praised be Jesus Christ! I am having issues displaying properly on the 2nd line of my LCD. After initializing, everything works great in the serial monitor. But when I try to use lcd.setCursor(10,1); to print the maxForce on the 2nd line it still displays the maxForce after the string on the 1st line instead of where I moved the cursor to. Any ideas? My code is attached if you can pin point the issue that would be very helpful. Merry Christmas Eve! I read a lot of the other posts but nothing seemed to help. Thank you!

#include <LiquidCrystal.h>
#include <math.h>
int FSR_PIN = A0; // Pin connected to FSR/resistor divider

const float VCC = 4.98; // Measured voltage of Ardunio 5V line

const float R_DIV = 3230.0; // Measured resistance of 3.3k resistor

float maxForce = 0;
LiquidCrystal lcd(1, 2, 4, 5, 6, 7);

void setup()

{
// set up the LCD’s number of columns and rows:
lcd.begin(16,2);
delay(100);
lcd.print(“Force(lb):”);
lcd.setCursor (0, 1);
delay(100);
lcd.print(“Max Force:”);

//lcd.setCursor (10, 0);

// initialize the serial communications:
Serial.begin(9600);

pinMode(FSR_PIN, INPUT);
}

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.

if (fsrADC != 0) // If the analog reading is non-zero

{

// Use ADC reading to calculate voltage:

float fsrV = fsrADC * VCC / 1023.0;

// Use voltage and static resistor value to

// calculate FSR resistance:

float fsrR = R_DIV * (VCC / fsrV - 1.0);

Serial.println(“Resistance: " + String(fsrR) + " ohms”);

// Guesstimate force based on slopes in figure 3 of

// FSR datasheet:

float force;

float fsrG = 1.0 / fsrR; // Calculate conductance

// Break parabolic curve down into two linear slopes:

if (fsrR <= 600)

force = (fsrG - 0.00075) / 0.00000032639;

else

force = fsrG / 0.000000642857;

CalculateMax(force);

Serial.println(“Force: " + String(force) + " g”);
Serial.println(“Max Force: " + String(maxForce) + " g”);
Serial.println();
//Serial.println();

lcd.setCursor(10, 0); // column, row
delay(100);
lcd.print(String(force));
delay(100);
lcd.setCursor(10, 1); // column, row
delay(100);
lcd.print(String(maxForce));
delay(100);

}

else

{
// No pressure detected
}
}

void CalculateMax(float _force){

if(_force > maxForce){

maxForce = _force;

} else{
return;
}
}

test_sep13a.ino (2.66 KB)

One thing that I notice is that you are using pin 1 for the LCD. Pin 1 is the Serial TX pin. You might want to use a different pin for the LCD.

Read the how to use this forum sticky to see how to properly post code.

PbJC! THANKS groundFungus you were correct! After days of troubleshooting, I changed the input to LiquidCrystal lcd(2, 3, 4, 5, 6, 7); and that did the trick thank you! I just said an extra prayer for you!