Display on lcd stay

Hello guys,

I’m new to Arduino. I just got this project.

I had set to 4 decimal places reading. seems good when the reading is 1 digit number with 4 decimal. but then, when 2 digit number, the decimal places shifted and when it comes back to 1 digit number with 4 decimal places, the last decimal at 5th stay. and that disturb my reading.

#include <LiquidCrystal.h>

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

int LEDpin = 10;
int LEDbrightness;
int buzzerpin = 9;
int buzzersound;
float fsrPin = 0;
float fsrReading;
float fsrVoltage;
float fsrResistance;
float fsrConductance;
float fsrForce;

void setup(void)
{
Serial.begin(9600);
lcd.begin(16, 2);
lcd.print(“Force:”);
pinMode(LEDpin, OUTPUT);
pinMode(buzzerpin, OUTPUT);
}

void loop(void) {
fsrReading = analogRead(fsrPin);

fsrVoltage = map(fsrReading, 0, 1023, 0, 5000);

if (fsrVoltage == 0) {
} else
{
fsrResistance = 5000 - fsrVoltage;
fsrResistance *= 10000;
fsrResistance /= fsrVoltage;

fsrConductance = 1000000;
fsrConductance /= fsrResistance;

if (fsrConductance <= 1000) {
fsrForce = fsrConductance / 80;
lcd.print(fsrForce, 4);
Serial.println(fsrForce);
} else {
fsrForce = fsrConductance - 1000;
fsrForce /= 30;
lcd.print(fsrForce, 4);
Serial.println(fsrForce);
}
}

lcd.setCursor(9, 0);

LEDbrightness = map(fsrReading, 0, 1023, 0, 255);
analogWrite(LEDpin, LEDbrightness);

buzzersound = map(fsrReading, 0, 1023, 0, 255);
analogWrite(buzzerpin, buzzersound);

delay(100);
}

I think the bug is:
When you wrote:
Force: 4.5678 wrote data 4.5678, display is OK
Force: 10.1234 wrote data 10.1234, display is OK
Force: 5.23454 wrote data 5.2345, display is NG
This is because you did clear the last character"4" of 10.1234.

The easy way to fix this bug is add a little code:

if (fsrConductance <= 1000)
{
fsrForce = fsrConductance / 80;
lcd.print(fsrForce, 4);
Serial.println(fsrForce);
}
else
{
fsrForce = fsrConductance - 1000;
fsrForce /= 30;
lcd.print(fsrForce, 4);
Serial.println(fsrForce);
}

if(fsrForce<10)
lcd.print(" ");